Front End Automation Strategies 1 – Don’t Write Complex XPath/CSS – Ask For Static Locators Instead

I am starting a series of posts on best strategies to be followed in front end automation. Here is the first post.

Locators‘ are the backbone of front end automation. Your script does not see the actual UI/UX and perform the action. It depends on DOM where HTML tags and its attributes are defined.

Maximum front end automation tool provides locators to locate web element of web page and perform desired actions on it. The best locator strategies are ID and NAME.

I see many web applications where developers do not provided proper attribute such as ID or name to HTML elements and automation testers try to write complex xpath/css to locate web element and may end up with unstable script. Minor changes in DOM structure may fail your test script. There is no meaning if you need to keep maintaining your scripts frequently because of locator issues. It takes time and effort.

Now a days automation is not the story to be done when application is completely build and stable. Many organization do it parallely with manual testing within sprint or some do only automation testing. So you can not waste time in just locating web elements.

We should ask for static locators preferrably an ID or unique name to web elements. I can list out some advantages of static locators below:

  1. It saves a lot of time as you just need to pick the ID or name and use.
  2. ID and Name are the fastest locators among all which may decrease your test execution time.
  3. Change in DOM structure will not impact your already created script much.
  4. You can focus more on validation rather than wasting time in finding locators.
  5. You can achieve stability of automation script. You must have experienced that max failures of automation script is because of locator issue.

If you are automating a web application which is under development, you must ask for it as completing a project successfully is a team’s responsibility. Providing proper locators is under developer control and which must be done for the sake of stability of project.

If you would like to share some best strategies you followed in your project, let me know by shooting an email at amod.mahajan@hotmail.com. I will love to share that knowledge with QA community with your details.

If you like my posts, please like, comment and share to reach maximum.

#ThanksForReading

Leave a Reply

Your email address will not be published. Required fields are marked *