Is string matches() supported in Selenium Webdriver 2?

Unfortunately, the matches() function is a part of XPath 2.0.

WebDriver uses the Wicked Good XPath library that only supports XPath 1.0.

Therefore, your XPath expression is illegal and you should rewrite it to only use features and functions from XPath 1.0.

I think you could simply replace the matches() call in your examply with contains(). That said, it’s not considered a good practise to match class names via contains(), because type-house would also match type-houses. Also if you match for propertytype type-house and the classes happen to be in different order, they won’t get matched. XPath doesn’t know anything about classes nor about space-separated lists used in CSS. For more discussion on this, see e.g. this.

You should really use a CSS selector instead:

dl.cN-featDetails > dd.propertytype.type-house

Leave a Comment