Accepted answer

You can use XPath Selectors with Symfony's DomCrawler.

To select your desired element use this XPath expression:

//td//small/span[@class="glyphicon glyphicon-pushpin"]

Then place it inside a PHPUnit assertion.

   $crawler->filterXPath('//td//small/span[@class="glyphicon glyphicon-pushpin"]')->count()

I've used assertEquals 1 as expected value, to ensure that one element is found on the page.


Actually, the question can be treated as a string match problem. There are several different ways to do that.

$ret = $html->find('td[class=*glyph]');

the pattern string may like /class="[^"]+glyph/

  • run grep command in the shell

$ grep glyph xxx.php

Related Query

More Query from same tag