-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathSmartuiIOS.java
More file actions
70 lines (58 loc) · 2.74 KB
/
Copy pathSmartuiIOS.java
File metadata and controls
70 lines (58 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import io.appium.java_client.AppiumBy;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.time.Duration;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class SmartuiIOS {
public static String userName = System.getenv("LT_USERNAME") == null ? "YOUR_LT_USERNAME" // Add username here
: System.getenv("LT_USERNAME");
public static String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "YOUR_LT_ACCESS_KEY" // Add accessKey here
: System.getenv("LT_ACCESS_KEY");
public static void main(String[] args) throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
Map<String, Object> ltOptions = new HashMap<>();
ltOptions.put("app", "lt://proverbial-ios"); // Enter your app url
ltOptions.put("deviceName", "iPhone 14");
ltOptions.put("platformName", "iOS");
ltOptions.put("isRealMobile", true);
ltOptions.put("build", "Java Test - iOS");
ltOptions.put("name", "Sample Test Java-iOS");
ltOptions.put("w3c", true);
ltOptions.put("video", true);
ltOptions.put("visual", true);
ltOptions.put("smartUI.project", "Real-Device-Project-IOS"); //Enter your smartUI Project name
capabilities.setCapability("lt:options", ltOptions);
AppiumDriver driver = new AppiumDriver(
new URL("https://" + userName + ":" + accessKey + "@mobile-hub.lambdatest.com/wd/hub"),capabilities);
try {
Thread.sleep(2000);
// Changes color
driver.findElement(AppiumBy.id("color")).click();
Thread.sleep(1000);
//Back to black color
driver.navigate().back();
Thread.sleep(1000);
//Changes the text to proverbial
driver.findElement(AppiumBy.id("Text")).click();
Thread.sleep(1000);
//toast is visible
driver.findElement(AppiumBy.id("toast")).click();
Thread.sleep(1000);
//notification is visible
driver.findElement(AppiumBy.id("notification")).click();
Thread.sleep(2000);
driver.executeScript("smartui.takeScreenshot=<Name of your Screenshot>");
System.out.println("Screenshot Captured");
// ((JavascriptExecutor) driver).executeScript("lambda-status=passed");
driver.quit();
} catch (Exception t) {
System.out.println(t);
driver.quit();
}
}
}