Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter by id with Symfony 2 Dom Crawler?

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?

like image 763
Sukhrob Avatar asked Oct 29 '12 09:10

Sukhrob


1 Answers

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']
like image 141
Igor Avatar answered Sep 22 '22 20:09

Igor