Reputation: 25237
I am crawling my html view with PHPUnit, using DomCrawler
$element = $crawler->filter("#myElement");
Once I have the element, how could I know the kind of tag that it is? (<input>
, <select>
, ...)
I know I could do this:
$element = $crawler->filter("input#myElement");
but I need to extract the name of the tag, and store it in a variable
Upvotes: 1
Views: 3505
Reputation: 33
Update: nowadays it is
$element = $crawler->filter("#myElement");
$name = $element->nodeName();
... which is actually a wrapper for
$crawler->getNode(0)->nodeName
Upvotes: 1
Reputation: 4628
As far as I can tell it, this should work:
$element = $crawler->filter("#myElement");
$name = $element->getNode(0)->tagName;
The Crawler::getNode(index)
returns a DOMElement that has the tagName
read only field.
Upvotes: 1