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 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号