Monday, December 15, 2008

Way to get XPATH in Internet Explorer

Are you stuck with an application that only works in IE?
Do you want the XPATH of an element that can be seen only IE? Unable to replicate the scenario in firefox. There are many firefox addons like xpather, xpath-checker and firebug that will give you the xpath of an element in a second. But sadly there is no addon or tool avaialable that will do this for IE. For most cases you can get the xpath of the elements that fall in your script using the above tools in firefox and tweak them a little (if required) to make them work in IE. But if you are testing an application that will work only in IE or the specific scenario or page that has this element will open-up/play-out only in IE then you cannot use any of the above mentione tools to find the XPATH.
Well the only thing that works in this case is the Bookmarklets that were coded just for this purpose. Bookmarklets are JavaScript code that you will add in IE as bookmarks and later use to get the XPATH of the element you desire. Using these you can get the XPATH as easily as you get using xpather or any other firefox addon.

1)Open IE
2)Type about:blank in the address bar and hit enter
3)From Favorites main menu select--->Add favorites
4) In the Add a favorite popup window enter name GetXPATH1.
5)Click add button in the add a favorite popup window.
6)Open the Favorites menu and right click the newly added favorite and select properties option.
7)GetXPATH1 Properties will open up. Select the web Document Tab.
8)Enter the following in the URL field.

javascript:function getNode(node){var nodeExpr=node.tagName;if(!nodeExpr)return null;if(!=''){nodeExpr+="[@id='""']";return "/"+nodeExpr;}var rank=1;var ps=node.previousSibling;while(ps){if(ps.tagName==node.tagName){rank++;}ps=ps.previousSibling;}if(rank>1){nodeExpr+='['+rank+']';}else{var ns=node.nextSibling;while(ns){if(ns.tagName==node.tagName){nodeExpr+='[1]';break;}ns=ns.nextSibling;}}return nodeExpr;}

9)Click Ok. Click YES on the popup alert.
10)Add another favorite by following steps 3 to 5, Name this favorite GetXPATH2 (step4)
11)Repeat steps 6 and 7 for GetXPATH2 that you just created.
12)Enter the following in the URL field for GetXPATH2

javascript:function o__o(){var currentNode=document.selection.createRange().parentElement();var path=[];while(currentNode){var pe=getNode(currentNode);if(pe){path.push(pe);if(pe.indexOf('@id')!=-1)break;}currentNode=currentNode.parentNode;}var xpath="/"+path.reverse().join('/');clipboardData.setData("Text", xpath);}o__o();

13)Repeat Step 9.

You are all done!!

Now to get the XPATH of elements just select the element with your mouse. This would involve clicking the left mouse button just before the element (link, button, image, checkbox, text etc) begins and dragging it till the element ends. Once you do this first select the favorite GetXPATH1 from the favorites menu and then select the second favorite GetXPATH2. At his point you will get a confirmation, hit allow access button. Now open up a notepad file, right click and select paste option. This will give you the XPATH of the element you seek.

*I got this bookmarklets from some other site but can't remember which one. Credit goes to the guy who created these JS.


Anonymous said...

Works like a charm! Thank you for sharing!

Anonymous said...

I found the code posted on Stack Overflow at:

The author is Phil Lho.

Anonymous said...

The person who wrote the code as well the person who shared it, a hearty thanks to both of them!!!!!!

Anonymous said...

For all those people who comments as,

"I found the code posted on Stack Overflow at:"

How many people did you share the information you found online. What to do who had written, bottom line is you found what you need.

Anonymous said...

Its really helpful to find Xpath value of a specific field..

Thanks to prepared and Shared information.

Anonymous said...

Thanks a tonn!!!

mathew said...

Thanks Man!!! It works. Also it there any way that i can verify some xpath?
Like the xpath which i get from Firefox or Chrome

Paras said...

Thanks Bro, It working.
Finally I know why my testcases was failing on IE.

Anonymous said...

Thanks Man!!!!!!!!Please keep up this good work......

man9ar00 said...

If you then need to test your XPath, you can use this technique:

Anonymous said...

This is awesome...Thanks for posting this... :)

Anonymous said...

Very Nice,

this is amazing :).

Thanks for you all

Anonymous said...

very very helpfull. I just tried it and working perfectly.

Anonymous said...

Hi Mahesh,

I did everything as mentioned in the post but not getting 'allow access button' or such things.

Can you please guide me on this.


MD.M Rahman said...

This is nice But if you like to find out some tree menu you can't select this little "+" sign to expand.For noncritical element this is good way.

Anonymous said...

it is helpful but i cant able to get xpath of the selected element in IE though i added getxpath1,2 to favourites sucessfully. i changed the security settings accrodingly but i cant able to retreive the xpath. pleae provide proper explanation. Thanks in advance.

pramod said...

thanks a lot .really helped me to solve my issue in IE


Hi All,
I felt very happy when I got this solution but it is not working for me in my application. I have followed the steps given in the blog and fetch the xpath of an webelement which is not at all working and equals to the xpath which has fetched by using chrome browser or firebug is working fine.
For example, below are the x-paths for a button in one the page and both are different.
1. //*[@id="save"] xpath fetched as per the steps given in blog is not working for me.
2. //INPUT[@id='save'] xpath fetched fropm chrome browser which is working fine.

Everyone who read this blog has given positive comments but not fine in my case. So, can any one of you help me out in this regard?

Anonymous said...

Just like a super and fantastic

Anonymous said...

It is fantastic. I was using Firefox to find the xpath but some applicaiton don't open on Firefox. God Bless!!


Anonymous said...

Hats off dude...grt work for both of them who made it and who shared it...Keep rocking

Mahesh Jajada said...

For me it is not working on IE11, worked pretty well on IE8 though. Does any setting on IE11 affecting this? Any idea?

Yethendra said...

Thanks a lot Buddy finally i got to know a way to find xpath in IE easily

Prabhakaran U said...

Hi everyone:
After reading this also am not able to get the xPATH for IE.please anyone guide me.

MY fb id is Prabhakar UVP

Anonymous said...

its mind blowing...someone else wrote the code...but u explained well....great..thanks it helped:)

Aliaa Monier Ismaail said...

Hello All

I searched alot , and tried alot , and unfortunately , the above technique didn't work on my side and I didn't receive the confirmation message to allow access , so I came up to the following technique and it worked fine:

* for the web page you want to view the XPATH of one of its elements , from IE >> right click the page >> view source >> copy the source file >> create a new text file >> paste the page source in it >> edit the extension to be filename.html >> right click the file and open with FireFox >> and as u should have FireBug installed >> select the item >> right click and Copy XPATH... Done :)

Thank you

Anonymous said...

It works fine but it does not use any IDs. Just shows the full path. Any way to see the IDs?

Pradeep Reddy said...

Excellent...worked like a charm...Fantastic.. thanks for the guy who shared this...hatsoff dude

Anonymous said...

This is simply wonderful ! I am just hoping it works for all objects I want ! Thanks to someone :)

Madan said...

First of all thanks for providing the solution, it works well for me.
But after capturing the first element xpath, the IE browser HTML is going to "Loading..." and i cannot inspect the second element, means the inspect is disabled after capturing first xpath

Can anybody help me on this.

Bhabapriya said...


I am unable to get the Xpath as the its throwing the error "Unable to create range for null reference error" while clicking the getXpath2 after clicking the getXpath1

Please advise

Akash Soori said...

Simply brilliant. Works without any issues. :) Thanks a lot man!!!

Rashmi M K said...

I observed it worked in one page initially, but doesnt work in another page.
Anybody faced similar issues ?

Please suggest.

Anonymous said...

This worked for me. Credit to dev and sharers :D

Shruti Ramalingam said...

Thanks for the great information in your blog Selenium Training in Chennai

RuThaN said...

Could someone pleas share video how to use it, pleas?
We are trying to do it for newest IE11 and Siebel OpenUI apliccation, but we are not able, but we are probably doing something wrong..

saurav said...

It's not working in IE11. Have to comeup with something new.

sanayamohit said...

Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.selenium Training in Chennai

Kumar Viren said...

Hello, '

I added the Xpath1 and Xpath2 but after that It is not working for me.
I select the element , select xpath1 then xpath2 but after when I paste into notepad then cant see the xpath.

Please advise to suggest the ans with screenshots...

vamshisays said...

Not working with IE11

Priya Kannan said...

That was a great message in my carrier, and It's wonderful commands like mind relaxes with understand words of knowledge by information's.
Selenium Training in Chennai

lascells said...

Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point. | |

Anonymous said...

I am not able to see that.Can anyone explain how to get the xpath more clearly and how and where the xpath will appear. Thanks

Anonymous said...

Great info. Thanks for sharing :)

Nicholas de said...

Hi, thanks for sharing such an informative blog. I have read your blog and I gathered some needful information from your blog. Keep update your blog. Awaiting for your next update.

QTP Training Videos

Ankit Sethiya said...

Every one who is saying it does not work in IE11 - just switch your browser to IE10 from inspect element and try again. worked for me! cheers. :) - Ankit

Anonymous said...

Wow almost gave up until I read the gentleman's comment to downgrade to IE 10 from 11 and it worked like a charm.

thanks mate - Henry W.

Chris ze said...

Really Thanks For Posting Such an Useful and informative article I gathered some needful information from your blog digital transformation consulting

ananthinfo said...

nice post..
SAP BUSINESS ONE for leather solution
ERP for leather solution
ERP leather garment solution
SAP BUSINESS ONE for leather garment solution
ERP for footwear solution

Sharmi Ammu said...

Thank you for this post!! I have just discovered your blog recently and I really like it! I will definitely try some of your insights.
Selenium Training in Chennai
selenium testing training in chennai
iOS Training in Chennai
testing training
testing Courses in Chennai

Prityyou said...

Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.
Airport Ground Staff Training Courses in Chennai | Airport Ground Staff Training in Chennai | Ground Staff Training in Chennai

Shadeep shree said...

Woow Excellent blog. Thanks for your informative blog.
Oracle dba Training
Oracle dba Certification
Oracle SQL Training
Oracle Training Courses
Oracle Database Certification

yuva rani said...

Thanks for sharing this valuable information to our vision. You have posted a worthy blog keep sharing.
English Speaking Classes in Mumbai
IELTS Classes in Mumbai
English Speaking Course in Mumbai
Spoken English Training in Bangalore
IELTS Center in Mumbai
Best English Speaking Classes in Mumbai
English Speaking Institute in Mumbai

Shiva Shakthi said...

The blog which you have posted is more useful for us. Thanks for your information.
IELTS Coaching Class in Coimbatore
IELTS Preparation
IELTS Coaching
IELTS Training Institute
IELTS Classes

dhivya said...

Nice article. I was really impressed by seeing this article, it was very interesting and it is very useful for me.
Computer Training Institute Franchise
Best Education Franchise In India
Training Franchise Opportunities In India
Language School Franchise
English Language School Franchise

Arunaram said...

This blog is really good.Your content is very creativity information. I learn more from this post.
Web Designing Training in Velachery
Web Designing Course in Chennai Velachery
Web Designing Training in Tnagar
Web Designing Training in Tambaram
Web Designing Course in Kandanchavadi
Web Designing Training in Sholinganallur

mercyroy said...

Amazing information,thank you for your ideas.after along time i have studied
an interesting information's.we need more updates in your blog.
AWS training courses near me
AWS Training in anna nagar
AWS Training in T nagar

Aruna ram said...

Nice Article!!! These Post is very good content and very useful information. I need more updates....
Data Science Training Institutes in Bangalore
Data Science in Bangalore
Data Science Course in Perambur
Data Science Training in Nolambur
Data Science Training in Saidapet
Data Science Classes near me

Sathish K said...

You have done an amazing job by posting this. Expecting more updates from you.

WordPress course
Wordpress Training Institute in Chennai
Wordpress Training Institute in Velachery
Wordpress Training Institute in Tambaram
Wordpress Training Institute in Adyar

mercyroy said...

Innovative thinking of you in this blog makes me very useful to learn.
i need more info to learn so kindly update it.
german language course in bangalore
German courses in Anna Nagar
German Certification Training in T nagar

aruna ram said...

Your blog is very creative and very helpful for me. I feel thanks to you for posting such a good blog, keep updates regularly..
SEO Course in Nungambakkam
SEO Training in Saidapet
SEO Course in Aminjikarai
SEO Course in Navalur
SEO Training in Kelambakkam
SEO Course in Karappakkam

Ananya Krishnan said...

Thank you for taking the time to write about this much needed subject. I felt that your remarks on this technology is helpful and were especially timely.

devops course fees in chennai | devops training in chennai with placement | devops training in chennai omr | best devops training in chennai quora | devops foundation certification chennai

pavithra dass said...

Great post and informative was awesome to read, thanks for sharing this great content to my vision.
Good discussion.
Android Development Course in Chennai
Android app Development Course in Chennai
Android Training Institute in Chennai
AWS Certification Training in Chennai
AWS Training near me
AWS Training in Chennai

venu bharath said...

Awesome Post. It shows your in-depth knowledge on the content. Thanks for sharing.

Xamarin Training in Chennai
Xamarin Course in Chennai
Xamarin Training
Xamarin Course
Xamarin Training Course
Xamarin Classes
Best Xamarin Course
Xamarin Training Institute in Chennai
Xamarin Training Institutes in Chennai

Riya Raj said...

The blog which you have shared here is more informative. Thanks for your blog.
selenium testing training
selenium testing course
selenium training classes
selenium classes
selenium training course

Riya Raj said...

The blog which you have shared is very useful for us. Thanks for your information.
Software Testing in Coimbatore
Software Testing Training in Coimbatore
Software Testing Course in Coimbatore with placement
Best Software Testing Training Institute in Coimbatore
Software Testing Training Center in Coimbatore

venu bharath said...

Awesome Post. It shows your in-depth knowledge on the content. Thanks for Sharing.
Informatica Training chennai
Informatica Training institutes in Chennai
Best Informatica Training Institute In Chennai
Best Informatica Training center In Chennai
Informatica Training
IELTS coaching in Chennai
IELTS Training in Chennai
IELTS coaching centre in Chennai

Shivani Yuvanjalin said...

This post is worth for me. Thank you for sharing.
ERP in Chennai
ERP Software in Chennai
SAP Business One in Chennai
SAP Hana in Chennai
SAP r3 in Chennai

cynthia williams said...

Learned a lot from your blog, keep up the good work and share more like this.
ReactJS Training in Chennai
ReactJS course in Chennai
ReactJS Training Institutes in Chennai
Angularjs Training in Chennai
Angular 5 Training in Chennai
Angularjs Training institute in Chennai

LindaJasmine said...

Great Article. The way you express is extra-ordinary. The information provided is very useful. Thanks for Sharing. Waiting for your next post.
SAS Training Chennai
SAS Training Institute in Chennai
SAS Courses in Chennai
SAS Training Center in Chennai
SAS Training in Velachery
SAS Training in Tambaram
SAS Training in Adyar
Photo Editing Courses in Chennai
Photoshop Training Institute in Chennai

Ananya Krishnan said...

Good job in presenting the correct content with the clear explanation. The content looks real with valid information. Good Work

DevOps is currently a popular model currently organizations all over the world moving towards to it. Your post gave a clear idea about knowing the DevOps model and its importance.

Good to learn about DevOps at this time.

devops training in chennai | devops training in chennai with placement | devops training in chennai omr | devops training in velachery | devops training in chennai tambaram | devops institutes in chennai | devops certification in chennai | trending technologies list 2018

Nadeem Malik said...

hello sir,
thanks for giving that type of information.
best digital marketing company in delhi
HP DesignJet T120 In Delhi

Ogen Infosystem said...

Hi dear, This is an nice and valuable post thanks for this information! Visit for lifestyle way at
Lifestyle Magazine India

Robotic Process Automation Tutorial said...

Thank you so much for your information,its very useful and helful to me.Keep updating and sharing. Thank you.
RPA training in chennai | UiPath training in chennai

Unknown said...

I tried the above mentioned steps, but unfortunately it did not work for me. Can you help me If I am trying anything wrong?


مروة محمد said...

شركة عزل اسطح بجازان

Akash Thakur said...

Thanks for giving great kind of information. So useful and practical for me. Thanks for your excellent blog, nice work keep it up thanks for sharing the knowledge.
dining room interior designer in noida

Vikash Kumar said...

nice work keep it up thanks for sharing the knowledge.Thanks for sharing this type of information, it is so useful.
tile bonder manufacturer in delhi

Amase LED Lighting said...

Thanks for giving great kind of information. So useful and practical for me. Thanks for your excellent blog, nice work keep it up thanks for sharing the knowledge.
Home Decor Wall Lights in delhi

رجب البرنس said...

بسم الله الرحمن الرحيم نحن فى شركة الكمال نقوم بجميع خدمات نقل العفش والاساس بافض الطرق تحت اشراف

فريق كبير مدرب على اعلى مستوى من المستويات مع الفك والتركيب
شركة نقل اثاث بالطائف
شركة نقل اثاث بجازان
شركة نقل اثاث بحائل
شركة نقل اثاث ونقل عفش بحائل
والسلامة عليكم ورحمة الله وبركاته

Rithi Rawat said...

Very nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
machine learning course in Chennai
machine learning with python course in Chennai
machine learning certification course in Chennai

Nisha Mathur said...

Nice information.. Thanks for sharing this blog. see my website also
.. VIEW MORE:- Website Designing Company in Delhi

vijaykumar said...

the article is nice.most of the important points are there.thankyou for sharing a good one.
RPA course in Chennai
RPA Training Institute in Chennai
Blue Prism Training Chennai
Blue Prism Training Institute in Chennai
UiPath Courses in Chennai
rpa Training in OMR
rpa Training in Adyar

luckys said...

whatsapp group links list

franklinraj said...

Thank you for excellent article.

Please refer below if you are looking for best project center in coimbatore

soft skill training in coimbatore
final year projects in coimbatore
Spoken English Training in coimbatore
final year projects for CSE in coimbatore
final year projects for IT in coimbatore
final year projects for ECE in coimbatore
final year projects for EEE in coimbatore
final year projects for Mechanical in coimbatore
final year projects for Instrumentation in coimbatore


Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
Thanks & Regards,
VRIT Professionals,
No.1 Leading Web Designing Training Institute In Chennai.

And also those who are looking for
Web Designing Training Institute in Chennai
SEO Training Institute in Chennai
Photoshop Training Institute in Chennai
PHP & Mysql Training Institute in Chennai
Android Training Institute in Chennai

Sivanandhana Girish said...

That was an awesome post. The author of the blog has shared fantastic info with the viewers.

Spoken English Classes in Velachery
Spoken English in Velachery
Spoken English Classes in Tambaram
Spoken English Class in Chrompet
Spoken English Classes in OMR Chennai
Spoken English Classes in Navalur
Spoken English Class in Ambattur
Spoken English Class in Avadi

lekha mathan said...

Very nice blog, Thank you for providing good information.
Aviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
best aviation academy in chennai
cabin crew training institute in chennai
Airline Courses in Chennai
airport ground staff training in chennai

yuva rani said...

Great info. The content you wrote is very interesting to read. This will loved by all age groups.
Angularjs Training in Chennai
Angularjs Course in Chennai
CCNA Training in Chennai
Salesforce Training in Chennai
Angular5 Training in Chennai
Angular6 Training in Chennai
Angular7 Training in Chennai
Angularjs Training in Chennai
Angularjs Course in Chennai

Anonymous said...

group link whatsapp
download lucky patcher android app
Pubg names
whatsapp dp
Lucky patcher
lucky patcher

IELTS Coaching in Dwarka said...

I feel happy about and learning more about this topic. keep sharing your information regularly for my future reference. This content creates new hope and inspiration within me. Thanks for sharing an article like this. the information which you have provided is better than another blog.
Best IELTS Coaching institute in Dwarka

Vicky Ram said...

Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog.
Keep update your blog.