0

I'm trying to send a form with PHPUnit. I followed the official documentation but I don't know what I'm doing wrong...

$client = static::createClient();
$crawler = $client->request('GET', '/demo/create/');
$form = $crawler->selectButton('Create Button')->form();

I have a submit button with Create Button text, but when I try the PHPUnit test I get the following error:

InvalidArgumentException: The current node list is empty.

I also tried filtering with form ID, but same error... What I'm doing wrong? I've created the form with the Form from Symfony 2.

Thanks.

1 Answer 1

1

It seems like the button is not found. Debug your page like this:

$client = static::createClient();
$crawler = $client->request('GET', '/demo/create/');
$button = $crawler->selectButton('Create Button');
var_dump($button);

so you can see if the button is actually found. Check for missing spaces / wrong capitalization in the button text.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.