Skip to content
Advertisement

How to check for a class present on an element with Symfony DOMcrawler?

I have a $foo which is an instance of Crawler and $foo->outerHtml() starts with <div class="brick brick--type--test brick--id--1. I am writing a test and I’d like to assert brick--id--1 is indeed present as a class. How could I do this? (preg_match() on $foo->outerHtml() invokes Cthulhu, I’d rather not)

Advertisement

Answer

Evaluate an XPATH expression against the nodes to check whether they contain the CSS class.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement