How to filter by id with Symfony 2 Dom Crawler?

functional-testing, phpunit, symfony

Solution

Symfony2 DOM Crawler filter internally uses DOMXPath, so you can find answer for your question on this thread

query for filter should be something like(note that code bellow is untested, I'm sure link above will help you)

//*[@id='elementId']

Problem

This works ``` $this->assertEquals(1, $crawler->filter('.elementClass')->count()); // filter by class ``` But, this doesn't seem to work. ``` $this->assertEquals(1, $crawler->filter('#elementId')->count()); // filter by id ``` Any ideas?

Original source

Related problems