minkphp / MinkBrowserKitDriver

Symfony2 BrowserKit driver for Mink framework
MIT License
549 stars 80 forks source link

The selected node does not have a form ancestor #120

Closed cduran433 closed 2 years ago

cduran433 commented 7 years ago

Hello,

I am using sonata admin bundle and I am creating the test with behat to be sure that everything is working fine. But the problem is that when I try to add a new element using behat I get this error:

The selected node does not have a form ancestor.

The problem is because this button is out of the form but this is managed by sonata admin. So is there any way to click this button without get this error?

aik099 commented 7 years ago

I'm not sure if BrowserKit supports this, but HTML allows for form attribute (value is ID of connected form) on form elements located outside of <form...> tag to associate form elements.

Not sure if that would help you can't change tested HTML.

cduran433 commented 7 years ago

The problem with sonata was that I have this element in the form and it seems that create an incorrect form :

->add('image', 'sonata_type_model_autocomplete', ['required' => false, 'property' => 'name']);

I change for this one and right now is working:

 ->add('image', 'sonata_type_model_list', ['required' => false]);
stof commented 2 years ago

if this a button handled in JS, the solution is to use a driver supporting JS