Right-click, Copy, Copy full XPath.
If you do this, your tests are doomed.
In the previous video, we learned why relying on CSS classes is a trap. We decided we need a "Heavy Weapon" to target elements by their text or unique attributes. That weapon is XPath.
But there is a wrong way to use it.
In this video (Part 5 of Locators Demystified), we are finally writing code! But it's not just theory - we run into a real-world problem where standard solutions fail, and we have to debug it live.
We will cover:
* Why the "Copy XPath" feature in Chrome creates garbage code.
* The difference between Absolute (Fragile) and Relative (Robust) XPath.
* The Magic Syntax: `//tag[@attribute='value']`.
* 🚨 LIVE DEBUGGING: Why `text()` failed on the login button and the "Dot Trick" (.) that saved the day.
* How to use `contains()` to make your locators bulletproof.
You will write your first solid locator today. No more guessing.
🔗 **PRACTICE ALONG WITH ME:**
Open the test app and your console here:
✅ **Want the deep dive?**
📌 TIMESTAMPS:
0:00 - The "Copy XPath" Mistake (Why your tests break)
01:29 - The Magic of "//" (Relative vs Absolute)
04:20 - Filtering by Attributes (The [@...] syntax)
06:40 - Targeting the "Soul" (The text() function)
07:47 - REAL WORLD PROBLEM: Why text() failed here? 🚨
08:47 - The "Dot" Trick (How to fix nested text issues)
10:09 - Making it Bulletproof (The contains() function)
11:37 - What if the tag changes? (Wildcards & Tags)
14:15 - Why "Copy XPath" is garbage (Live Demo)
---
Testeroni is a channel dedicated to demystifying test automation for manual QA engineers.
#TestAutomation #SoftwareTesting #QA #ManualTester #Selenium #Playwright #Locators