From ea0286f86e1e6ecc3a3e46749aa13a1dd333c91b Mon Sep 17 00:00:00 2001 From: adityaj Date: Wed, 26 Mar 2025 20:42:09 +0530 Subject: [PATCH 1/5] updated readme --- README.md | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a8a2e02..8b98257 100644 --- a/README.md +++ b/README.md @@ -1 +1,78 @@ -# smartui-sdk-utils \ No newline at end of file +# LambdaTest Java SDK + + +Run the following command to install the dependencies of the project mentioned in `pom.xml`: + +```sh +mvn clean install +``` + +Set the required environment variables: + +```sh +export PROJECT_TOKEN= +export LT_ACCESS_KEY= +export LT_USERNAME= +``` + +## Usage + +### Using the App Screenshot Function + +#### 1. Create an Object of `SmartUIAppSnapshot` + +```java +SmartUIAppSnapshot smartUIAppSnapshot = new SmartUIAppSnapshot(); +``` + +#### 2. Add Screenshot Config for Taking a Screenshot + +```java +Map screenshotConfig = new HashMap<>(); +screenshotConfig.put("deviceName", "Google Pixel 9"); +screenshotConfig.put("platform", "Android 15"); + +try { + smartUIAppSnapshot.start(); // Starts the auth process and creates the build + smartUIAppSnapshot.smartuiAppSnapshot(driver, "screenshot1", screenshotConfig); // Takes a screenshot and uploads to SmartUI server + smartUIAppSnapshot.stop(); +} catch (Exception e) { + e.printStackTrace(); +} +``` + +### Using the Web Screenshot Function + +#### 1. Install the `smartui-cli` Dependencies + +```sh +npm i @lambdatest/smartui-cli +``` + +#### 2. Create and Configure SmartUI Config + +```sh +npx smartui config:create smartui-web.json +``` + +#### 3. Use Local Hub + +```sh +npx smartui exec -- mvn test -D suite=sdk-local.xml +``` + +#### 4. Use LambdaTest Cloud Hub + +```sh +npx smartui exec -- mvn test -D suite=sdk-cloud.xml +``` + +Your test results will be displayed on the test console (or command-line interface if you are using terminal/cmd) and on the SmartUI dashboard. + +## Executing SmartUI Test on LambdaTest Hub Without `smartui-cli` + +The tests can be executed in the terminal using the following command: + +```sh +mvn test -D suite=smartui.xml +``` From 3114e82347c29616fbfab81bb96860d5bb7804ce Mon Sep 17 00:00:00 2001 From: adityaj Date: Wed, 26 Mar 2025 21:25:39 +0530 Subject: [PATCH 2/5] updated readme --- README.md | 61 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 8b98257..ca20f49 100644 --- a/README.md +++ b/README.md @@ -22,25 +22,35 @@ export LT_USERNAME= #### 1. Create an Object of `SmartUIAppSnapshot` ```java -SmartUIAppSnapshot smartUIAppSnapshot = new SmartUIAppSnapshot(); -``` - -#### 2. Add Screenshot Config for Taking a Screenshot - -```java -Map screenshotConfig = new HashMap<>(); -screenshotConfig.put("deviceName", "Google Pixel 9"); -screenshotConfig.put("platform", "Android 15"); - -try { - smartUIAppSnapshot.start(); // Starts the auth process and creates the build - smartUIAppSnapshot.smartuiAppSnapshot(driver, "screenshot1", screenshotConfig); // Takes a screenshot and uploads to SmartUI server - smartUIAppSnapshot.stop(); -} catch (Exception e) { - e.printStackTrace(); +import java.util.HashMap; +import java.util.Map; + +public class SmartUITest { + public static void main(String[] args) { + Map screenshotConfig = new HashMap<>(); + screenshotConfig.put("deviceName", "Google Pixel 9"); + screenshotConfig.put("platform", "Android 15"); + + SmartUIAppSnapshot smartUIAppSnapshot = new SmartUIAppSnapshot(); + + try { + smartUIAppSnapshot.start(); // Start authentication and create the build + smartUIAppSnapshot.smartuiAppSnapshot(driver, "screenshot1", screenshotConfig); // Capture screenshot + } catch (Exception e) { + System.err.println("Error capturing SmartUI snapshot: " + e.getMessage()); + e.printStackTrace(); + } finally { + try { + smartUIAppSnapshot.stop(); // Ensure stop is always called + } catch (Exception ex) { + System.err.println("Error stopping SmartUI session: " + ex.getMessage()); + } + } + } } ``` + ### Using the Web Screenshot Function #### 1. Install the `smartui-cli` Dependencies @@ -54,6 +64,21 @@ npm i @lambdatest/smartui-cli ```sh npx smartui config:create smartui-web.json ``` +```java +import io.github.lambdatest.SmartUISnapshot; + +public class SmartUISDK { + + private RemoteWebDriver driver; + + @Test + public void basicTest() throws Exception { + driver.get("https://www.lambdatest.com/support/docs/smartui-selenium-java-sdk"); + SmartUISnapshot.smartuiSnapshot(driver, "visual-regression-testing"); + } + +} +``` #### 3. Use Local Hub @@ -67,10 +92,6 @@ npx smartui exec -- mvn test -D suite=sdk-local.xml npx smartui exec -- mvn test -D suite=sdk-cloud.xml ``` -Your test results will be displayed on the test console (or command-line interface if you are using terminal/cmd) and on the SmartUI dashboard. - -## Executing SmartUI Test on LambdaTest Hub Without `smartui-cli` - The tests can be executed in the terminal using the following command: ```sh From 47f80ad72fc1ecbedd8b3e5cf35f3c21fdafb152 Mon Sep 17 00:00:00 2001 From: adityaj Date: Wed, 26 Mar 2025 21:27:20 +0530 Subject: [PATCH 3/5] updated readme --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index ca20f49..0c8984a 100644 --- a/README.md +++ b/README.md @@ -91,9 +91,3 @@ npx smartui exec -- mvn test -D suite=sdk-local.xml ```sh npx smartui exec -- mvn test -D suite=sdk-cloud.xml ``` - -The tests can be executed in the terminal using the following command: - -```sh -mvn test -D suite=smartui.xml -``` From 67d2c1fe874ab7fa2a2262dfb2bdf98d694cb581 Mon Sep 17 00:00:00 2001 From: adityaj Date: Wed, 26 Mar 2025 21:39:18 +0530 Subject: [PATCH 4/5] refactored as per review comment --- README.md | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 0c8984a..48a82da 100644 --- a/README.md +++ b/README.md @@ -17,41 +17,24 @@ export LT_USERNAME= ## Usage -### Using the App Screenshot Function - +### To Take Smartui App Snapshot +`import io.github.lambdatest.SmartUIAppSnapshot;` #### 1. Create an Object of `SmartUIAppSnapshot` ```java -import java.util.HashMap; -import java.util.Map; - -public class SmartUITest { - public static void main(String[] args) { + SmartUIAppSnapshot smartUIAppSnapshot = new SmartUIAppSnapshot(); Map screenshotConfig = new HashMap<>(); - screenshotConfig.put("deviceName", "Google Pixel 9"); - screenshotConfig.put("platform", "Android 15"); + screenshotConfig.put("deviceName","Google pixel 9"); + screenshotConfig.put("platform","Android 15"); - SmartUIAppSnapshot smartUIAppSnapshot = new SmartUIAppSnapshot(); - - try { - smartUIAppSnapshot.start(); // Start authentication and create the build - smartUIAppSnapshot.smartuiAppSnapshot(driver, "screenshot1", screenshotConfig); // Capture screenshot - } catch (Exception e) { - System.err.println("Error capturing SmartUI snapshot: " + e.getMessage()); - e.printStackTrace(); - } finally { - try { - smartUIAppSnapshot.stop(); // Ensure stop is always called - } catch (Exception ex) { - System.err.println("Error stopping SmartUI session: " + ex.getMessage()); - } - } - } -} + smartUIAppSnapshot.start(); + smartUIAppSnapshot.smartuiAppSnapshot(driver, "screenshot1", screenshotConfig); + smartUIAppSnapshot.stop(); + ``` -### Using the Web Screenshot Function +### To Take Smartui Snapshot #### 1. Install the `smartui-cli` Dependencies From b6d700b92af8147dcc884e12fe2ba622ce5bb56b Mon Sep 17 00:00:00 2001 From: adityaj Date: Thu, 27 Mar 2025 22:26:07 +0530 Subject: [PATCH 5/5] Final commit - updated readme --- README.md | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 48a82da..e2cac6a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # LambdaTest Java SDK - Run the following command to install the dependencies of the project mentioned in `pom.xml`: ```sh @@ -17,7 +16,7 @@ export LT_USERNAME= ## Usage -### To Take Smartui App Snapshot +### To Take SmartUI App Snapshot `import io.github.lambdatest.SmartUIAppSnapshot;` #### 1. Create an Object of `SmartUIAppSnapshot` @@ -34,7 +33,7 @@ export LT_USERNAME= ``` -### To Take Smartui Snapshot +### To Take SmartUI Snapshot #### 1. Install the `smartui-cli` Dependencies @@ -61,16 +60,4 @@ public class SmartUISDK { } } -``` - -#### 3. Use Local Hub - -```sh -npx smartui exec -- mvn test -D suite=sdk-local.xml -``` - -#### 4. Use LambdaTest Cloud Hub - -```sh -npx smartui exec -- mvn test -D suite=sdk-cloud.xml -``` +``` \ No newline at end of file