Skip to content

Commit ef5789d

Browse files
committed
auto heal readme
1 parent 6044e64 commit ef5789d

File tree

6 files changed

+30
-283
lines changed

6 files changed

+30
-283
lines changed

README.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
* [Pre-requisites](#pre-requisites)
3030
* [Run Your First Test](#run-your-first-test)
31-
* [Parallel Testing With JUnit](#run-parallel-tests-using-junit)
3231
* [Local Testing With JUnit](#testing-locally-hosted-or-privately-hosted-projects)
3332

3433
## Pre-requisites
@@ -53,11 +52,11 @@ Before you can start performing Java automation testing with Selenium, you would
5352

5453
### Cloning Repo And Installing Dependencies
5554

56-
**Step 1:** Clone the LambdaTest’s JUnit-Selenium-Sample repository and navigate to the code directory as shown below:
55+
**Step 1:** Clone the LambdaTest’s junit-autoheal-sample repository and navigate to the code directory as shown below:
5756

5857
```bash
59-
git clone https://github.com/LambdaTest/junit-selenium-sample
60-
cd junit-selenium-sample
58+
git clone -b junit-autoheal-sample https://github.com/LambdaTest/junit-selenium-sample
59+
cd junit-autoheal-sample
6160
```
6261

6362
You may also want to run the command below to check for outdated dependencies.
@@ -68,7 +67,7 @@ mvn versions:display-dependency-updates
6867

6968
### Setting Up Your Authentication
7069

71-
Make sure you have your LambdaTest credentials with you to run test automation scripts. You can get these credentials from the [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) or by your [LambdaTest Profile](https://accounts.lambdatest.com/login?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample).
70+
Make sure you have your LambdaTest credentials with you to run test automation scripts. You can get these credentials from the [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build?utm_source=github&utm_medium=repo&utm_campaign=junit-autoheal-sample) or by your [LambdaTest Profile](https://accounts.lambdatest.com/login?utm_source=github&utm_medium=repo&utm_campaign=junit-autoheal-sample).
7271

7372
**Step 2:** Set LambdaTest **Username** and **Access Key** in environment variables.
7473

@@ -86,50 +85,47 @@ Make sure you have your LambdaTest credentials with you to run test automation s
8685

8786
## Run Your First Test
8887

89-
>**Test Scenario**: Checkout sample [JUnitTodo.java](https://github.com/LambdaTest/junit-selenium-sample/blob/master/src/test/java/com/lambdatest/JUnitTodo.java) file. This JUnit Selenium script tests a sample to-do list app by marking couple items as done, adding a new item to the list and finally displaying the count of pending items as output.
88+
>**Test Scenario**: This test automates the process of searching for a book titled "Python Programming" in the Books category on Amazon.in using the LambdaTest platform.
89+
90+
**📋 Test Steps**
91+
- The script initializes a remote WebDriver session on LambdaTest with the desired capabilities (Windows 10, Chrome browser).
92+
- The Amazon.in website is loaded.
93+
- **The script updates the ID attributes of the search submit button and search textbox.**
94+
- The search category dropdown is clicked to reveal the list of categories.
95+
- The 'Books' category is selected from the dropdown.
96+
- The term "Python Programming" is entered into the search textbox.
97+
- The search button is clicked to initiate the search.
98+
99+
With `AutoHeal` Enable, the test scenario passed even after updating the ID attribute of submit button.
90100

91101
### Configuring your Test Capabilities
92102

93103
**Step 3:** In the test script, you need to update your test capabilities. In this code, we are passing browser, browser version, and operating system information, along with LambdaTest Selenium grid capabilities via capabilities object. The capabilities object in the above code are defined as:
94104

95105
```java
96-
DesiredCapabilities capabilities = new DesiredCapabilities();
97-
capabilities.setCapability("browserName", "chrome");
98-
//capabilities.setCapability("platform", "Windows 10"); // If this cap isn't specified, it will just get the any available one
99-
capabilities.setCapability("build", "LambdaTestSampleApp");
100-
capabilities.setCapability("name", "LambdaTestJavaSample");
101-
// capabilities.setCapability("network", true); // To enable network logs
102-
// capabilities.setCapability("visual", true); // To enable step by step screenshot
103-
// capabilities.setCapability("video", true); // To enable video recording
104-
// capabilities.setCapability("console", true); // To capture console logs
106+
DesiredCapabilities desiredCaps = new DesiredCapabilities();
107+
desiredCaps.setCapability("LT:Options", new DesiredCapabilities() {
108+
{
109+
setCapability("build", "Auto Heal Demo");
110+
setCapability("name", "Auto Heal Test" );
111+
setCapability("autoHeal", true);
112+
}
113+
});
114+
desiredCaps.setCapability("browserName", "Chrome");
105115
```
106116

107-
You can generate capabilities for your test requirements with the help of our inbuilt [Desired Capability Generator](https://www.lambdatest.com/capabilities-generator/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample).
117+
You can generate capabilities for your test requirements with the help of our inbuilt [Desired Capability Generator](https://www.lambdatest.com/capabilities-generator/?utm_source=github&utm_medium=repo&utm_campaign=junit-autoheal-sample).
108118

109119
### Executing the Test
110120

111121
**Step 4:** The tests can be executed in the terminal using the following command.
112122

113123
```bash
114-
mvn test -P single
124+
export AUTOHEAL=true; mvn test -P autoheal
115125
```
116126

117127
Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on [LambdaTest automation dashboard](https://automation.lambdatest.com/build).
118128

119-
## Run Parallel Tests Using JUnit
120-
121-
Check out the [Parallelized.java](https://github.com/LambdaTest/junit-selenium-sample/blob/master/src/test/java/com/lambdatest/Parallelized.java) class we have used for running our Parallel Tests using JUnit.
122-
123-
124-
Check out the [JUnitConcurrentTodo.java](https://github.com/LambdaTest/junit-selenium-sample/blob/master/src/test/java/com/lambdatest/JUnitConcurrentTodo.java) file for executing parallel test using JUnit automation framework.
125-
126-
### Executing Parallel Tests Using JUnit
127-
128-
To run parallel tests using **JUnit**, we would have to execute the below command in the terminal:
129-
130-
```bash
131-
mvn test -P parallel
132-
```
133129

134130
## Testing Locally Hosted Or Privately Hosted Projects
135131

pom.xml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
<artifactId>lambdatest-junit-sample</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010

11-
12-
13-
14-
1511
<properties>
1612
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1713
<surefire.version>2.19.1</surefire.version>
@@ -70,41 +66,6 @@
7066
</build>
7167

7268
<profiles>
73-
74-
<profile>
75-
<id>parallel</id>
76-
<build>
77-
<plugins>
78-
<plugin>
79-
<groupId>org.apache.maven.plugins</groupId>
80-
<artifactId>maven-surefire-plugin</artifactId>
81-
<configuration>
82-
<includes>
83-
<include>com/lambdatest/JUnitConcurrentTodo.java</include>
84-
</includes>
85-
</configuration>
86-
</plugin>
87-
</plugins>
88-
</build>
89-
</profile>
90-
91-
<profile>
92-
<id>single</id>
93-
<build>
94-
<plugins>
95-
<plugin>
96-
<groupId>org.apache.maven.plugins</groupId>
97-
<artifactId>maven-surefire-plugin</artifactId>
98-
<configuration>
99-
<includes>
100-
<include>com/lambdatest/JUnitTodo.java</include>
101-
</includes>
102-
</configuration>
103-
</plugin>
104-
</plugins>
105-
</build>
106-
</profile>
107-
10869
<profile>
10970
<id>autoheal</id>
11071
<build>

src/test/java/com/lambdatest/AutoHealDemoTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void setUp() throws Exception {
2323
desiredCaps.setCapability("LT:Options", new DesiredCapabilities() {
2424
{
2525
setCapability("build", "Auto Heal Demo");
26-
setCapability("name", "Auto Heal" +AUTO_HEAL.toUpperCase() );
26+
setCapability("name", "Auto Heal " +AUTO_HEAL.toUpperCase() );
2727
setCapability("autoHeal", AUTO_HEAL);
2828
setCapability("geoLocation", "IN");
2929
}
@@ -42,6 +42,7 @@ public void tearDown() {
4242
@Test
4343
public void testDemoSite() throws InterruptedException {
4444
loadAmazonWebsite();
45+
if (AUTO_HEAL.equalsIgnoreCase("true"))
4546
updateLocators();
4647
searchBookAndGoToCart();
4748
}
@@ -89,12 +90,8 @@ public void searchBookAndGoToCart() {
8990
public void loadAmazonWebsite() throws InterruptedException {
9091
System.out.println("Loading URL");
9192
driver.get("https://www.amazon.com");
92-
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
93+
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
9394
TimeUnit.SECONDS.sleep(10);
9495
System.out.println("Page Loaded Successfully.");
9596
}
96-
97-
public static void main(String[] args) {
98-
org.junit.runner.JUnitCore.main("AutoHealDemoTest");
99-
}
10097
}

src/test/java/com/lambdatest/JUnitConcurrentTodo.java

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/test/java/com/lambdatest/JUnitTodo.java

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)