Selected node has no shape ancestor - Mink error

I am trying to run tests on my Magento installation using Mink with the Goutte driver and it fails when I try to use buttons click()

or press()

on a button.

code:

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

      

How do you get this job? Why does Minke need a form to click a button element? Or is the problem related to the fact that Goutte cannot get the JS?

+3


source to share


2 answers


TL; DR: Use a different driver or make sure the form elements are inside the form.

The Goutte driver is pretty awesome, but not as awesome as a real browser. It receives the content of the response and uses the Grapte scrapper to parse it. To add some spice to testing, it allows you to enter and submit form data by intercepting calls to setting values ​​and storing the form data in an object. When you click on a button (I'm only assuming on type="submit"

) that form the data is added to the request data and sent to the server.



To create this shape object, it looks for the closest parent shape to get the main shape details. Thus, when you try to set an input value that is not part of a form, or submit without a form - it cannot find the form and throws an exception.

Ensuring that form elements are positioned inside the form tag should solve such problems. Alternatively, you can use the Selenium2 driver - it uses a completely different mechanism.

+2


source


The problem is with the DOM. I was able to debug by placing <button>

closer to <form>

in the DOM tree.



In my case the problem was with some <script>

blocks (angular templates) inside <form>

.

+1


source







All Articles