Skip to content

Commit d73b9f2

Browse files
Aditya JoshiAditya Joshi
Aditya Joshi
authored and
Aditya Joshi
committed
Added code for app profiles
1 parent 7299b54 commit d73b9f2

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

pom.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
<artifactId>selenium-support</artifactId>
4242
<version>4.16.1</version>
4343
</dependency>
44-
<dependency>
45-
<groupId>io.appium</groupId>
46-
<artifactId>java-client</artifactId>
47-
<version>8.3.0</version>
48-
</dependency>
4944
<!-- https://mvnrepository.com/artifact/io.github.lambdatest/lambdatest-java-sdk -->
5045
<dependency>
5146
<groupId>io.github.lambdatest</groupId>
5247
<artifactId>lambdatest-java-sdk</artifactId>
5348
<version>1.0.8</version>
5449
</dependency>
50+
<dependency>
51+
<groupId>io.appium</groupId>
52+
<artifactId>java-client</artifactId>
53+
<version>8.3.0</version>
54+
</dependency>
5555
<dependency>
5656
<groupId>org.testng</groupId>
5757
<artifactId>testng</artifactId>

src/test/java/SmartUIAppAndroid.java renamed to src/test/java/SmartuiAppAndroid.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
import java.util.HashMap;
1010
import java.util.Map;
1111

12-
public class SmartUIAppAndroid {
12+
public class SmartuiAppAndroid {
1313
public static String userName = System.getenv("LT_USERNAME") == null ? "YOUR_LT_USERNAME" // Add username here
1414
: System.getenv("LT_USERNAME");
1515
public static String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "YOUR_LT_ACCESS_KEY" // Add accessKey here
1616
: System.getenv("LT_ACCESS_KEY");
17+
public static String projectToken = System.getenv("PROJECT_TOKEN") == null ? "YOUR_PROJECT_TOKEN" // Add project token here
18+
: System.getenv("PROJECT_TOKEN");
19+
1720

1821
public static void main(String[] args) throws Exception {
1922
DesiredCapabilities caps = new DesiredCapabilities();
@@ -30,23 +33,18 @@ public static void main(String[] args) throws Exception {
3033
ltOptions.put("smartUI.project", "Real-Device-Project-Android"); // Enter your smartUI Project name
3134
caps.setCapability("lt:options", ltOptions);
3235

33-
36+
Map<String, String> startConfig= new HashMap<>();
37+
startConfig.put("projectToken", projectToken);
3438

3539
AppiumDriver driver = new AppiumDriver(
3640
new URL("https://"+userName+":"+accessKey+"@mobile-hub.lambdatest.com/wd/hub"), caps);
37-
String projectToken = "<<enter-project-token>>";
38-
String buildName = "<<enter-your-cutomised-build-name>>";
3941

4042
SmartUIAppSnapshot smartUIAppSnapshot = new SmartUIAppSnapshot();
41-
Map<String, String> startConfig= new HashMap<>();
42-
startConfig.put("projectToken", projectToken);
43-
startConfig.put("buildName", buildName);
44-
4543
Map<String, String> screenshotConfig = new HashMap<>();
4644
screenshotConfig.put("deviceName","Google pixel 9");
4745
screenshotConfig.put("platform","Android 15");
4846
try{
49-
smartUIAppSnapshot.start(startConfig); //We can also call start w/o any param, values set from env vars
47+
smartUIAppSnapshot.start(); //we can also call start w/o options it'll take projectToken from env var
5048
driver.findElement(AppiumBy.id("com.lambdatest.proverbial:id/color")).click();
5149
smartUIAppSnapshot.smartuiAppSnapshot(driver, "screenshot1", screenshotConfig);
5250
driver.findElement(AppiumBy.id("com.lambdatest.proverbial:id/Text")).click();

src/test/java/SmartuiAppIos.java

+7-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public class SmartuiAppIos {
1212
: System.getenv("LT_USERNAME");
1313
public static String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "YOUR_LT_ACCESS_KEY" // Add accessKey here
1414
: System.getenv("LT_ACCESS_KEY");
15+
public static String projectToken = System.getenv("PROJECT_TOKEN") == null ? "YOUR_PROJECT_TOKEN" // Add project token here
16+
: System.getenv("PROJECT_TOKEN");
17+
1518

1619
public static void main(String[] args) throws Exception {
1720
DesiredCapabilities caps = new DesiredCapabilities();
@@ -28,30 +31,24 @@ public static void main(String[] args) throws Exception {
2831
ltOptions.put("smartUI.project", "Real-Device-Project-iOS"); // Enter your smartUI Project name
2932
caps.setCapability("lt:options", ltOptions);
3033

34+
Map<String, String> startConfig= new HashMap<>();
35+
startConfig.put("projectToken", projectToken);
3136

3237
AppiumDriver driver = new AppiumDriver(
3338
new URL("https://"+userName+":"+accessKey+"@mobile-hub.lambdatest.com/wd/hub"), caps);
34-
String projectToken = "<<enter-project-token>>";
35-
String buildName = "<<enter-your-cutomised-build-name>>";
3639

3740
SmartUIAppSnapshot smartUIAppSnapshot = new SmartUIAppSnapshot();
38-
Map<String, String> startConfig= new HashMap<>();
39-
startConfig.put("projectToken", projectToken);
40-
startConfig.put("buildName", buildName);
41-
4241
Map<String, String> screenshotConfig = new HashMap<>();
4342
screenshotConfig.put("deviceName","iPhone 16");
4443
screenshotConfig.put("platform","iOS 17");
4544
try{
46-
smartUIAppSnapshot.start(startConfig); //We can also call start w/o any param, values set from env vars
45+
smartUIAppSnapshot.start(startConfig); //We can also call start w/o options it'll take projectToken from env var
4746
driver.findElement(AppiumBy.id("color")).click();
4847
smartUIAppSnapshot.smartuiAppSnapshot(driver, "screenshot1", screenshotConfig);
4948
Thread.sleep(3000);
50-
5149
driver.navigate().back();
5250
Thread.sleep(1000);
53-
54-
driver.findElement(AppiumBy.id("com.lambdatest.proverbial:id/Text")).click();
51+
driver.findElement(AppiumBy.id("Text")).click();
5552
smartUIAppSnapshot.smartuiAppSnapshot(driver, "screenshot2", screenshotConfig);
5653
Thread.sleep(3000);
5754
} catch (Exception e) {

0 commit comments

Comments
 (0)