douduanque5850 2014-08-20 09:28
浏览 33
已采纳

所选节点没有表单祖先 - Mink错误

I'm trying to perform tests on my Magento installation using Mink with Goutte driver, and it fails when I'm trying to use click() or press() functions on a button.

Code:

$page = $this->getSession()->getPage();
    $checkout = $page->find('css', '.btn-proceed-checkout');
    $checkout->click();

How to get this work? Why does Mink actually need a form to click a button element? Or is that the problem connected with Goutte not being able to fetch JS?

  • 写回答

2条回答 默认 最新

  • douxiegan6468 2014-08-20 10:57
    关注

    TL;DR: use different driver or make sure form elements are actually inside the form.

    Goutte driver is pretty awesome, but not as awesome as the real browser. It gets the response content and uses Goutte scrapper to analyse it. To add some spice your testing it allows you to enter and submit form data by intercepting value setting calls and storing form data in the object. When you click on a button (I'd assume only on type="submit") that form data is added into request data and sent to the server.

    In order to create that form object it searches for the closest parent form to get the basic form details. So, when you try to set a value on the input that is not part of the form, or do a submit without a form – it can't find the form and throws an exception.

    Ensuring that form elements sit inside the form tag should resolve such issues. Alternatively you can use Selenium2 driver – it uses a completely different mechanism.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题