How to Become Genius in XPath in Selenium - Session -18

Naveen AutomationLabs · 786K views · 2017 · 39:48

Open on YouTube

Testing, debugging & developer toolsWeb developmenttutorial

Why Stack Overflow recommends it

Stack Overflow users link it when they tell someone to stop using Chrome's auto-generated 'Copy XPath' and learn to write short, reliable selectors themselves.

Recommended by 3 people across 3 different months, 2021 to 2022.

What it is

A 40-minute Selenium WebDriver tutorial from Naveen AutomationLabs on writing XPath expressions by hand. It covers building and testing custom XPaths in Chrome, text() and contains(), and the parent and preceding-sibling axes for dynamic elements.

What people said

Recommends Swaroop Humane · 2021-04 · Stack Overflow · on “Get TD element from Table”

Actually if i will explain it will become very long. Better i will give you resource which you can see and read to get better understanding of Xpaths. First refer [this video] youtube video and also read about xpath axes from [LINK] Do let me know if you need more explanation and dont forget to mark it as answer. :)

Recommends JD2775 · 2021-06 · Stack Overflow · on “Best way to get XPATH and CSS SELECTORS for scraping with Selenium”

You are correct that right-clicking and Copy Xpath is a bad way to get an Xpath. You are left with a long and brittle selector. It is much better to build your own. Once you get the hang of it, it is pretty simple to start building your own CSS and Xpath selectors. Some of them get complicated but if you keep practicing and searching for solutions you will get better and better. The problem is it is very difficult to explain how to do it in a forum like this. Your best bet is to YouTube some videos on how to create Xpath and CSS selectors for Selenium. Here is a decent one I just found for Xpath: [this video] This follows the approach I use in Chrome Dev Tools and using the built in Find window (

Recommends Souvik_07 · 2022-08 · Stack Overflow · on “How to get text from a dynamic label id HTML field using its relative xpath in Katalon?”

The answer to the above problem is to create customized xpaths for all elements which needs to be captured. For example: Creating an xpath for the Ask Question button above. //a[@class="ws-nowrap s-btn s-btn__primary"] To learn more about how to create unique customized xpaths for all types of element, please watch this video:( [this video] ). I think xpaths are a very usefull tool to access any kind of elements present in any website. To use the xpaths in katalon by using Selenium drivers : Package files : import org.openqa.selenium.By as By import org.openqa.selenium.Keys as Keys import org.openqa.selenium.WebDriver as WebDriver import org.openqa.selenium.WebElement as WebElement Code : driver.