An open API service indexing awesome lists of open source software.

https://github.com/hjsblogger/auto-healing-with-selenium

This repo deep dives into running Auto-Healing tests using Selenium and LambdaTest
https://github.com/hjsblogger/auto-healing-with-selenium

auto-healing automation-testing lambdatest selenium selenium-java selenium-webdriver

Last synced: 7 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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:

* [LambdaTest E-commerce Playground Registration Page](https://ecommerce-playground.lambdatest.io/index.php?route=account/register)
* [LambdaTest E-commerce Playground Product Page](https://ecommerce-playground.lambdatest.io/index.php?route=product/category&path=57)
* [Demo Login Page created by Florin Pop](https://codepen.io/FlorinPop17/pen/vPKWjd)

The [Demo Login Page](https://codepen.io/FlorinPop17/pen/vPKWjd) 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](https://www.lambdatest.com/support/docs/underpass-tunnel-application/#downloading--installing-the-underpass-tunnel-application) from LambdaTest to establish an SSH tunnel between the OS & LambdaTest cloud server(s).

UnderPass

Load the [demo login page](https://github.com/hjsblogger/auto-healing-with-selenium/tree/main/local-project/dist/index.html) 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](https://accounts.lambdatest.com/detail/profile) page.

SecurityPage

For macOS:

```bash
export LT_USERNAME=LT_USERNAME
export LT_ACCESS_KEY=LT_ACCESS_KEY
```

For Linux:

```bash
export LT_USERNAME=LT_USERNAME
export LT_ACCESS_KEY=LT_ACCESS_KEY
```

For Windows:

```bash
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](https://github.com/hjsblogger/auto-healing-with-selenium/blob/main/Makefile)

![Code1](https://github.com/hjsblogger/auto-healing-with-selenium/assets/1688653/fe2fec54-9c67-4bd7-a352-81b58bbd50c7)

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](https://github.com/hjsblogger/auto-healing-with-selenium/assets/1688653/296771b4-5fe4-416e-9c94-2e3d08f6b34f)

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](https://automation.lambdatest.com/build) 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](https://www.lambdatest.com/support/docs/auto-healing/)

## 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](mailto:himanshu.sheth@gmail.com) for any queries or ping me on the following social media sites:

LinkedIn: [@hjsblogger](https://linkedin.com/in/hjsblogger)

Twitter: [@hjsblogger](https://www.twitter.com/hjsblogger)