Selenium Locators Tutorial: Types, Best Practices, and many more

The skill of building robust Selenium locators is both science and art. This skill stems from a special kind of intuition that you can only attain while working on real-life projects. Most QAs agree it takes months, sometimes years, to develop this intuition. So what is it that makes Selenium locators a pain point? Building locators that last is easy if you’re dealing with elements that have unique IDs. Things are still fairly straightforward if you can add missing IDs every time you need them. But is this a realistic expectation in real-life projects? Sadly, no. In real life, we always stumble across hard-to-reach stuff. Dynamically generated IDs, duplicate IDs, missing IDs, renamed IDs, pieces of legacy code, you name it. More often than not, you don’t get the luxury of asking a developer to assign an ID to each element you target. In situations of this sort, the efficiency of test automation will depend on your knowledge of Selenium locators and best practices related to them. Let’s have a quick look at the tactics of targeting UI elements in Selenium tests. In this post, we’ll look at the types of Selenium locators, as well as the advantages they offer... More
WordPress Image Lightbox Plugin