3

I get an "InvalidArgumentException: The current node list is empty." error with my functional 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.
Community
  • 1
  • 1
Grogro2000
  • 31
  • 2
  • 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 '15 at 17:42
  • 1
    try adding `name="SUBMIT"` – Matteo Mar 12 '15 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 '15 at 09: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 : ``. I will look for an unclosed tag. – Grogro2000 Mar 15 '15 at 21:49

0 Answers0