5 Tips to Distinguish Good and Bad Locators

Why reading these tips?

Tip #1. Long texts are usually BAD

Tip #2. XPath axes are very handy sometimes

  • Find the <a> tag whose @href attribute contains the string ‘skuId=6139660’.
  • Based on that <a> tag, find all of its ancestors (parent, grandparents, great grandparent, etc.).
  • Among those ancestors, pick the one that is a <div> with the @class attribute equal to ‘row’.
  • Based on that <div>, look for all tags inside of that <div> and pick out the <select> tag.
  • Bingo. Since each row only contains one <select> tag, that <select> ought to be the Quantity dropdown list we’re looking for.

Tip #3. Treat tables as tables

Tip #4. Avoid absolute paths at all cost

Tip #5. Always test your XPath


About The Author




www.pombuilder.com | https://logigear.github.io/pombuilderblog

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Convert API Log Data into Actionable Information

Five Months of Gamedev with Elm

Hive City progress in September demonstrating basic character movement

Autel MaxiLink ML529 OBD2 Scanner Car Auto Diagnostic Tool OBD 2 EOBD Code Reader Full OBDII…

Java 13 — New enhanced switch

The Blackbook Project (Part 3)

A Black Book

A Simpler Guide to Flutter Navigator 2.0: Part III

Online Backup Solutions in Waterperry #Cloud #Backup #Solutions #Waterperry https://t.co/o1hqfbbHRY

Google Cloud AI Platform Notebooks and Cloud Source Repositories

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
POM Builder Development Team

POM Builder Development Team

www.pombuilder.com | https://logigear.github.io/pombuilderblog

More from Medium

Cypress — counting the number of elements on a page

Questions To Ask (And Answer) Before Setting Up A Test Automation Framework

Part 1 : Test Driven Development — the basics

Basics of Structured Query Language