KallDrexx
KallDrexx

Reputation: 27833

How can I quickly check if a xpath is valid in IE?

I am evaluating using Selenium to perform automated testing of my company's Asp.net Webforms application. Since most of the html ids are auto-generated I am trying to rely on xpaths to be able to interact with my page.

As I am knew to xpaths, I am having issues trying to pinpoint the exact xpath I need to click on this element. The process of changing my coded xpath, compiling my C# app, loading the app, running the app, then having Selenium exception out is getting pretty annoying. I need to find some way to quickly determine if an xpath is valid (i.e. exists) or not.

Unfortunately, they coded this site to only work in IE, so that is all i have access to.

If someone has a good quick way for me to test an xpath out in IE, I would be very grateful!

Upvotes: 14

Views: 28354

Answers (6)

browsermator
browsermator

Reputation: 1354

You could use my little java project, The Browsermator, to run/check your routines first: https://www.browsermator.com It would save you the trouble of re-running builds all the time.

Upvotes: 0

iamsankalp89
iamsankalp89

Reputation: 4749

You can use the with Fire-IEBrowser.xlsm a google project application,

This will help you to find XPath of web elements in IE

You can find this application here

Also, you can find the more better solution in this answer

Upvotes: 0

dansek
dansek

Reputation: 139

Do F12 on the IE browser and copy the html. Then open the notepad and paste the html and save it as .html file. Finally you got the html page, then you can open the saved file in Firefox fox browser for validating xpath with firebug or firepath.

Upvotes: 0

Dmytro Zharii
Dmytro Zharii

Reputation: 291

As I am knew to xpaths, I am having issues trying to pinpoint the exact xpath I need to click on this element. The process of changing my coded xpath, compiling my C# app, loading the app, running the app, then having Selenium exception out is getting pretty annoying.

I've created SWD Page Recorder for this purpose. It can work with all browsers supported by Selenium WebDriver and allows to debug, test and save locators for further editing.

When you download Page Recorder, please, put the Internet Explorer driver near the executable: IE Driver Download page

Upvotes: 0

David
David

Reputation: 3441

This StackOverflow post has some links to techniques for finding XPath in IE.

Finding an elements XPath using IE Developer tool

I particularly like this solution in that post: http://functionaltestautomation.blogspot.com/2008/12/xpath-in-internet-explorer.html

However, to test/verify your XPath, whether found from such tools or you defined it yourself, you may want to do something like this (if you're thinking something similar to what FirePath provides for XPath/CSS validity verification):

http://autumnator.wordpress.com/2013/05/02/testing-xpath-and-css-locators-firepath-style-across-browsers/

Upvotes: 0

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243599

Use the XPath Visualizer.

This is a popular tool that through the years has taught XPath the fun way to thousands of developers.

You first load an XML file and then can enter any XPath expressions and see the selected nodes immediately hi-lighted in the XML document. There are many more features, even for experienced developers.

The XPath Visualizer can be downloaded here.

Upvotes: 1

Related Questions