Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I get an "InvalidArgumentException: The current node list is empty." error with my functionnal tests on Symfony2.

According to different posts I have wrote the following code :

In the Test Class :

$client = static::createClient();
$crawler = $client->request('GET', 'http://localhost/site/web/app_dev.php/en/offer');
$buttonCrawlerNode = $crawler->selectButton('SUBMIT');
$form = $buttonCrawlerNode->form();
$form['travelComment'] = 'Hey there!';

In the twig :

<form method="post" {{ form_enctype(form) }}>
    {{ form_widget(form) }}
    <input value="SUBMIT" type="submit" class="btn btn-primary" />     
</form>

As you can see the input value SUBMIT is the same in the selectbutton function.

Then I get the following message :

InvalidArgumentException: The current node list is empty.

Please, does anybody have an idea ?

Thanks !!!

share|improve this question
1  
Please add the rendered HTML code, by looking at the source of the page from your computer. Look closely at the question you linked: did you forgot the name of the form e.g. form[travelComment]? –  A.L Mar 12 at 17:42
1  
try adding name="SUBMIT" –  Matteo Mar 12 at 18:49
    
Have you solved? Try investigating on the structure of the generated html: if your html is not valid, i.e. an unclused tag, the crawler don't work as expecected. Hope this help –  Matteo Mar 14 at 9:30
1  
Thks for your help. I have tried with name="SUBMIT" with no result. I still have the same message. The rendered HTML code seems to be good : <input name="SUBMIT" value="SUBMIT" type="submit" class="btn btn-primary">. I will look for an unclosed tag. –  Grogro2000 2 days ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.