Easy way to find XPath to elements.

sukhoi35
sukhoi35 used Ask the Experts™
on
Experts, I have started working on Selenium and would need your help in finding XPATH of webpage elements in browsers. If there is any tutorial using which I can help find the right xpath to elements using developer tools, it will greatly help. Thanks.

Just to add, I have used the chrome Inspect Element -> XPath option, but would like to know if there are other non-browser tools or plugins which are more friendlier and descriptive.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Andrew LeniartIT Professional | Freelance Journalist | Looking for Opportunities
Distinguished Expert 2018
Commented:
Hi Sukoi35,

Not a topic I'm particularly familiar with myself but have you checked the excellent resources available in the Articles section of Experts Exchange?

Perhaps the answer you're looking for is there?  

Here's a search result you may like to check;

https://www.experts-exchange.com/searchResults.jsp?searchTerms=Selenium&rtid=30&searchSubmit=

I hope that's helpful.

Regards, Andrew
Director of Customer Relations
Commented:
Hi sukhoi35,

One word of warning, I would try to stay away from XPATHs unless you absolutely have to. I've found that css selectors or ids make more readable code and tend to break less than XPATHs. Check out the Katalon Automation Recorder add-on for Chrome and Firefox. It makes it a bit easier to see the different selectors available and locate items in the page. You can record clicking the element and then select from the drop down to see the available selectors. You can use it to record steps and export crude code to get the job done, but I have always preferred to structure the automation logic first then fill in the selectors.

This article has a good write up on how to use CSS selectors.

Regards,

Craig

Author

Commented:
Dear Andrew and Craig,
Thanks for your responses. Craig, I will surely consider your suggestion. Andrew, thanks for the excellent resource, it looks like it contains many of the other things I was actually looking for.
Andrew LeniartIT Professional | Freelance Journalist | Looking for Opportunities
Distinguished Expert 2018

Commented:
You're very welcome Sukhoi35. Glad I was able to help a little.

Regards, Andrew
Craig KehlerDirector of Customer Relations

Commented:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial