-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)DomCrawlerStalled
Description
I've been using the DomCrawler to create functional tests for a little while now. While it's a very robust and easy to use component, a major pain point is whenever a test fails with an InvalidArgumentException: "The current node list is empty".
I use these kind of constructs frequently:
$crawler = $browser->request('GET', '/');
$crawler = $browser->submit($crawler->filter('#some-form')->form(), [
/* form values */
]);
or:
$messageContent = $crawler->filter('ul li.message-content')->text();
Methods such as form()
and text()
will fail if the crawler cannot find the selector.
While PHPUnit of course provides the exact line number where the error occurred, I think it would improve DX a lot if the error message contained more information such as the CSS/XPath selectors that were used.
For example:
InvalidArgumentException : No nodes matched the selector '#some-form'
I would have no issue making a PR for this issue, but since it would be my first time contributing I thought I'd seek more input first.
pedzed
Metadata
Metadata
Assignees
Labels
DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)DomCrawlerStalled