DEV Community

Tejas Deshpande
Tejas Deshpande

Posted on • Originally published at

Self Healing UI Test Automation

Getting Started

Simulating human-machine interactions using UI Automation tools has been one of the best productivity improvements in validating application quality in a scalable and performant manner.

However the possibility of dynamic selector(s) has always caused flaky tests and has been the cause for major reservations for many.

Although experts know ways to robustly develop/fix automated UI tests, they are quite ill perceived by many others and are thereby avoided.

We are going to checkout an easy way handle those dynamic selectors using TestProject.

TestProject provides us with a self healing test automation platform which renews failing locator using AI to identify new locators.

Here is how it works...

For the sake of this tutorial I will be focusing on the test creation part.

For the installation guide check here.

Test Setup

  1. Create a new test by clicking on and setting any desired name.
  2. For this tutorial select Web as the test type. And click Next.
    Details (Step: 1 & 2) New Test
  3. Now on the Select web application dialog, click on the Web applications dropdown and select Add a new application for testing. I will be using the the internet heroku app for this tutorial. To follow along set following parameters:
Name: internet heroku app
Enter fullscreen mode Exit fullscreen mode

Details New Application

  1. Since the AI based Self Healing functionality is available in the Web interface of TestProject, select to store the test on the cloud.
  2. For simplicity's sake I have used the recording feature to get you familiar with the UI of the test editor. This is the same UI that will assist us later to stabilize identification of the dynamic elements.
    Details Get Started

Test Steps

  1. Launch the internet heroku app.
  2. Click on Dynamic Content link.
    Details TestSteps
  3. Select the first paragraph on the page for Dynamic Content and check if it is correctly recognized by highlighting it in the UI.
    Details SelectFirstPara
  4. Refresh page and try to highlight the same element again. This time it will fail since initially the achor was the text content itself which has now changed.
    Details refreshpage
    Now things get interesting. We have arrived at the stage where the dynamic element is not recognized by the automation. Now think... how can we fix this... Think of all the ways in which you can fix this test to make it robust. Once you're done, read the next step.
  5. Fixing the dynamic locator failure is as simple as re-running the test or specific step. TestProject will run AI analysis and finds a replacement locator. To avoid AI bias, you get approval over the selections.
    Details updatelocator
  6. Once confirmed go back to the test and re-run it as many times as you like and the dynamic content is handled just fine.

Using the power of AI to automatedly fix dynamic locators could never have been any easier. Although many coders are skeptical about record-playback style tools, I urge all to give it a shot. It just might be worth your time.

For more detailed illustration, refer following video:

Top comments (0)