Skip to content

This repo deep dives into running Auto-Healing tests using Selenium and LambdaTest

Notifications You must be signed in to change notification settings

hjsblogger/auto-healing-with-selenium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Healing in Selenium using LambdaTest

In this 'Auto Healing in Selenium using LambdaTest' repo, we have covered the following use cases:

  • Auto Healing of live document
  • Auto Healing of document (under development)

The following websites are used for the purpose of demoing the use cases:

The Demo Login Page is hosted locally and run on port number 8080 (or any other port) that is currently free on the system.

Pre-requisites for test execution

For localhost testing, we need to start the tunnel. To do the same, download Underpass from LambdaTest to establish an SSH tunnel between the OS & LambdaTest cloud server(s).

UnderPass

Load the demo login page by triggering the php -S localhost:8080 command on the terminal.

TestMethod_3 1

Before running the tests on LambdaTest Selenium Grid, you need to set the environment variables - LT_USERNAME and LT_ACCESS_KEY. Here is how you can do the same:

Configure Environment Variables

Before the tests are run, please set the environment variables LT_USERNAME & LT_ACCESS_KEY from the terminal. The account details are available on your LambdaTest Profile page.

SecurityPage

For macOS:

export LT_USERNAME=LT_USERNAME
export LT_ACCESS_KEY=LT_ACCESS_KEY

For Linux:

export LT_USERNAME=LT_USERNAME
export LT_ACCESS_KEY=LT_ACCESS_KEY

For Windows:

set LT_USERNAME=LT_USERNAME
set LT_ACCESS_KEY=LT_ACCESS_KEY

Also, add LT_USERNAME and LT_ACCESS_KEY in the set-env section in the Makefile

Code1

Run make set-env to export the desired environment variables (i.e. LT_USERNAME and LT_ACCESS_KEY).

Test Execution

Execution of tests [with unchanged locators]

To start with, we run the tests (with original locators) by invoking make org-test to execute tests that have locators that have not been modified during the development process. Hence, we will not observe any auto-healing of locators in this test execution cycle.

Make3

Test execution is triggered with all three tests running in parallel on LambdaTest Selenium Grid.

Make-Org-Test-New make-org-test-completed

Shown below is the execution snapshot which indicates that the test execution was successful.

org-test-dashboard-running org-test-dashboard-completed

Execution of tests [with healed locators]

The test code with modified locators is present in AutoHealingTest.java Run the command make auto-heal to execute the tests that have locators healed by the auto-healing algorithm.

Make-Auto-Heal-New Test_auto-healing-dashboard-1

As seen below, the test execution was successful. However, there is a small bandage icon (for indicating healed tests) next to the respective tests. This indicates that the tests are healed when potential failures are encountered during the course of test execution.

Auto-Healing-Terminal Auto-Healing-Dashboard-2


Navigate to the respective test in the LambdaTest dashboard and click on the Bandage icon to view details of the test.

Healed-Locator-in-Testing


For further reference, please visit Official Documentation of Auto Healing on LambdaTest

Have feedback or need assistance?

Feel free to fork the repo and contribute to make it better! Email to himanshu[dot]sheth[at]gmail[dot]com for any queries or ping me on the following social media sites:

LinkedIn: @hjsblogger
Twitter: @hjsblogger