What XPath version does a given WebDriver support?

1 minute read

Ever wondered what version of XPath does a given WebDriver support? We certainly wished it would be 2.0 or 3.0, but most likely the version is 1.0. Don’t take my word for it, though, let’s see some data.

As Selenium wiki states, WebDriver uses the browser’s native XPath capabilities wherever possible. When the browser does not support XPath (IE 6/7/8, I’m looking at you), Selenium provides its own implementation, supporting XPath 1.0 (with some caveats, see wiki).

If you need a “generic” method that’d decide if the WebDriver you’re using supports XPath 1.0 or 2.0, the code below can be of help.

Does Selenium WebDriver support XPath 2.0?

Here’s something that may work for you:

The principle is simple: try a function specific to the XPath version you want to know if the browser supports.

Does Selenium WebDriver support XPath 3.0?

Same basis, you could test for XPath 3.0 support using:

What’s the veredict?

Bad news. Even XPath 2.0 support is very poor among WebDriver implementations. So chances are all you got is 1.0.

I couldn’t find any supporting 2.0. Can you?


PS.: I realize those snippets are coding by exception. Trust me, though, other than making a table enumerating all WebDrivers XPath versions, to this date, there is no other way of knowing it.

Tags: , , ,

Categories:

Updated:

Leave a Comment