Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verify XPath is valid with developer tools in Internet Explorer 8

I'm writing Selenium tests, and I need to support Internet Explorer 8.

I want to use Developer Tools in Internet Explorer 8 to verify that Internet Explorer 8 can find certain elements by their XPath expressions. I can do this easily using Chrome of Firebug with Firefox, but I can't figure out how to do it with IE Developer Tools -- it feels very clunky, foreign, and unintuitive for someone coming from Chrome and and Firebug with Firefox.

I'm not trying to get an element's XPath expression with Developer Tools. (The web has plenty of links for how to do that.) I'm trying to verify that XPath expressions which I already have will work in Internet Explorer 8 using Developer Tools.

If I want to verify that an XPath expression finds an element in Chrome, I would:

  • Navigate to the page I want to verify
  • Press F12 to bring up Chrome debugger
  • Press Ctrl + F to bring up find
  • Type or paste in the XPath expression that I want to test
  • See if the XPath expression found an element.

Here is an image of what it looks like in Chrome:

Verifying an XPath expression in Chrome

I would like to do the same thing in Internet Explorer 8. How can I do this?

I have seen Equivalent of Firebug's “Copy Xpath” in Internet Explorer? which tries to get the XPath expression from the webelement. I'm trying to do the opposite: get the webelement from the XPath expression to verify the XPath expression is valid in Internet Explorer 8.

like image 514
James Dunn Avatar asked Mar 17 '14 21:03

James Dunn


1 Answers

This isn't possible, or at least easily.

Internet Explorer (any version) doesn't have a native XPath engine. The way Selenium works around this is by using a JavaScript library to do it, called Wicked Good XPath.

https://code.google.com/p/wicked-good-xpath/

My only suggestion would be to inject WGX into your page and then use it directly in the console.

You can, however, still execute CSS selectors natively in the IE Developer Tools console - but this is little consolation for your XPath needs.

like image 112
Arran Avatar answered Oct 10 '22 08:10

Arran