Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use xpath 2.0 with firefox and selenium?

I saw other questions referring to xpath 2.0, which apparently simplifies string expressions. I'm using Firefox 3.5.5 and selenium 1.0.1.

  • How can I check if my versions of Firefox and Selenium support it?
  • Does Selenium defer to Firefox's built-in Xpath implementation?
  • In that case, if I start using another (perhaps older) browser with selenium, will I run into problems by expecting xpath 2.0?
like image 853
Paul Biggar Avatar asked Dec 20 '09 16:12

Paul Biggar


People also ask

Does Firefox support XPath?

It uses a non-XML syntax so that it can be used in URIs and XML attribute values. Note: Support for XPath varies widely; it's supported reasonably well in Firefox (although there are no plans to improve support further), while other browsers implement it to a lesser extent, if at all.

What version of XPath does selenium use?

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).

Is XPath same for all browsers?

Xpath is same across all browsers.

Is XPath same in Chrome and Firefox?

No. XPaths are interpreted in the same way everywhere.


2 Answers

By default, selenium uses the "native" version of XPath that comes with the browser. You can make it use a version that comes with Selenium, written in JavaScript. This seems to implement XPath 1.0, based on glancing at the source.

like image 80
Paul Biggar Avatar answered Oct 07 '22 17:10

Paul Biggar


I think there is a jQuery plugin that gives you support for XPath 2.0. So, theoretically, if you inject jQuery and the plugin into your browser, maybe you could call XPath 2.0 commands with a JavascriptExecutor. Really, its probably not necessary though, but might be fun to play with.

like image 39
djangofan Avatar answered Oct 07 '22 19:10

djangofan