Skip to content

Commit baf643f

Browse files
authored
Merge pull request #3 from sushobhit-lt/main
fix java local sdk sample
2 parents 8cf8a53 + 1869503 commit baf643f

File tree

9 files changed

+2978
-69
lines changed

9 files changed

+2978
-69
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.project
44
.settings
55
.theia
6+
node_modules/*

README.md

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ cd smartui-java-testng-sample
5252
You can also run the command below to check for outdated dependencies.
5353

5454
```bash
55-
mvn versions:display-dependency-updates
55+
mvn clean compile
5656
```
5757

5858
### Setting Up Your Authentication
@@ -64,41 +64,47 @@ Make sure you have your LambdaTest credentials with you to run test automation s
6464
- For **Linux/macOS**:
6565

6666
```bash
67+
export PROJECT_TOKEN="xxxxx#java-sdk-testing"
6768
export LT_USERNAME="YOUR_USERNAME"
6869
export LT_ACCESS_KEY="YOUR ACCESS KEY"
6970
```
7071

7172
- For **Windows**:
7273

7374
```bash
75+
set PROJECT_TOKEN="xxxxx#java-sdk-testing"
7476
set LT_USERNAME="YOUR_USERNAME"
7577
set LT_ACCESS_KEY="YOUR ACCESS KEY"
7678
```
7779

78-
## Run Your First Test
80+
### Execute SmartUI Java Tests using smartui-cli
7981

80-
> **Test Scenario**: The sample [TestNGTodo1.java](https://github.com/LambdaTest/Java-TestNG-Selenium/blob/master/src/test/java/com/lambdatest/TestNGTodo1.java) 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.
8182

82-
### Configuring Your Test Capabilities
83+
#### Install the smartui-cli dependencies
84+
```bash
85+
npm i @lambdatest/smartui-cli
86+
```
8387

84-
**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:
88+
#### Create and Configure SmartUI Config
89+
```bash
90+
npx smartui config:create smartui-web.json
91+
```
8592

86-
```java
87-
DesiredCapabilities capabilities = new DesiredCapabilities();
88-
capabilities.setCapability("browserName", "chrome");
89-
capabilities.setCapability("version", "latest");
90-
capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
91-
capabilities.setCapability("build", "LambdaTestSampleApp");
92-
capabilities.setCapability("name", "LambdaTestJavaSample");
93-
capabilities.setCapability("smartUI.project", "testng-smartui-project");
93+
#### Use Local Hub
94+
```bash
95+
npx smartui exec -- mvn test -D suite=sdk-local.xml
96+
```
9497

98+
#### Use Lambdatest Cloud Hub
99+
```bash
100+
npx smartui exec -- mvn test -D suite=sdk-cloud.xml
95101
```
96102

97-
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=Java-TestNG-Selenium).
103+
Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on SmartUI dashboard.
98104

99-
### Executing The SmartUI Test
105+
### Executing SmartUI Test on Lambdatest Hub without smartui-cli
100106

101-
**Step 4:** The tests can be executed in the terminal using the following command.
107+
The tests can be executed in the terminal using the following command.
102108

103109
```bash
104110
mvn test -D suite=smartui.xml
@@ -108,35 +114,14 @@ Your test results would be displayed on the test console (or command-line interf
108114

109115
## Run Parallel SmartUI Tests Using TestNG
110116

111-
Here is an example `xml` file which would help you to run a single test on various browsers at the same time, you would also need to generate a testcase which makes use of **TestNG** framework parameters (`org.testng.annotations.Parameters`).
112-
113-
```xml title="smartui-parallel.xml"
114-
<?xml version="1.0" encoding="UTF-8"?>
115-
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
116-
<suite thread-count="20" parallel="tests" name="Suite">
117-
<test thread-count="20" parallel="classes" name="Test">
118-
<classes>
119-
<class name="com.lambdatest.TestNGSmartUIChrome"/>
120-
<class name="com.lambdatest.TestNGSmartUIFirefox"/>
121-
</classes>
122-
</test>
123-
</suite>
124-
```
125-
126117
### Executing Parallel Tests Using TestNG
127118

128119
To run parallel tests using **TestNG**, we would have to execute the below commands in the terminal:
120+
```bash
121+
mvn test -D suite=smartui-parallel.xml
122+
```
129123

130-
- For the above example code
131-
```bash
132-
mvn test
133-
```
134-
- For the cloned Java-TestNG-Selenium repo used to run our first sample test
135-
```bash
136-
mvn test -D suite=smartui-parallel.xml
137-
```
138-
139-
### Executing SmartUI Real Device Tests
124+
### Execute SmartUI Real Device Tests
140125

141126
The tests can be executed in the terminal using the following command.
142127

0 commit comments

Comments
 (0)