|
1 |
| -# smartui-sdk-utils |
| 1 | +# LambdaTest Java SDK |
| 2 | + |
| 3 | +Run the following command to install the dependencies of the project mentioned in `pom.xml`: |
| 4 | + |
| 5 | +```sh |
| 6 | +mvn clean install |
| 7 | +``` |
| 8 | + |
| 9 | +Set the required environment variables: |
| 10 | + |
| 11 | +```sh |
| 12 | +export PROJECT_TOKEN=<add-your-project-token> |
| 13 | +export LT_ACCESS_KEY=<add-your-access-key> |
| 14 | +export LT_USERNAME=<add-your-username> |
| 15 | +``` |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +### To Take SmartUI App Snapshot |
| 20 | +`import io.github.lambdatest.SmartUIAppSnapshot;` |
| 21 | +#### 1. Create an Object of `SmartUIAppSnapshot` |
| 22 | + |
| 23 | +```java |
| 24 | + SmartUIAppSnapshot smartUIAppSnapshot = new SmartUIAppSnapshot(); |
| 25 | + Map<String, String> screenshotConfig = new HashMap<>(); |
| 26 | + screenshotConfig.put("deviceName","Google pixel 9"); |
| 27 | + screenshotConfig.put("platform","Android 15"); |
| 28 | + |
| 29 | + smartUIAppSnapshot.start(); |
| 30 | + smartUIAppSnapshot.smartuiAppSnapshot(driver, "screenshot1", screenshotConfig); |
| 31 | + smartUIAppSnapshot.stop(); |
| 32 | + |
| 33 | +``` |
| 34 | + |
| 35 | + |
| 36 | +### To Take SmartUI Snapshot |
| 37 | + |
| 38 | +#### 1. Install the `smartui-cli` Dependencies |
| 39 | + |
| 40 | +```sh |
| 41 | +npm i @lambdatest/smartui-cli |
| 42 | +``` |
| 43 | + |
| 44 | +#### 2. Create and Configure SmartUI Config |
| 45 | + |
| 46 | +```sh |
| 47 | +npx smartui config:create smartui-web.json |
| 48 | +``` |
| 49 | +```java |
| 50 | +import io.github.lambdatest.SmartUISnapshot; |
| 51 | + |
| 52 | +public class SmartUISDK { |
| 53 | + |
| 54 | + private RemoteWebDriver driver; |
| 55 | + |
| 56 | + @Test |
| 57 | + public void basicTest() throws Exception { |
| 58 | + driver.get("https://www.lambdatest.com/support/docs/smartui-selenium-java-sdk"); |
| 59 | + SmartUISnapshot.smartuiSnapshot(driver, "visual-regression-testing"); |
| 60 | + } |
| 61 | + |
| 62 | +} |
| 63 | +``` |
0 commit comments