-
Notifications
You must be signed in to change notification settings - Fork 23
/
vanilla_ios.java
100 lines (76 loc) · 3.75 KB
/
vanilla_ios.java
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import io.appium.java_client.MobileBy;
import io.appium.java_client.MobileElement;
import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.net.URL;
public class vanilla_ios {
public static String userName = System.getenv("LT_USERNAME") == null ? "YOUR_USERNAME" // Add username here
: System.getenv("LT_USERNAME");
public static String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "YOUR_ACCESS_KEY" // Add accessKey here
: System.getenv("LT_ACCESS_KEY");
public static final String URL = "https://" + userName + ":" + accessKey + "@mobile-hub.lambdatest.com/wd/hub";
public static IOSDriver driver = null;
public static void main(String[] args) throws Exception {
try {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platformVersion", "15");
caps.setCapability("deviceName", "iPhone 12");
caps.setCapability("isRealMobile", true);
caps.setCapability("app", "APP_URL"); // Enter your app url
caps.setCapability("platformName", "iOS");
caps.setCapability("build", "Java Vanilla - iOS");
caps.setCapability("name", "Sample Test Java");
caps.setCapability("devicelog", true);
caps.setCapability("network", false);
driver = new IOSDriver(
new URL("https://" + userName + ":" + accessKey + "@mobile-hub.lambdatest.com/wd/hub"),
caps);
Thread.sleep(2000);
// Changes color
driver.findElement(MobileBy.id("color")).click();
Thread.sleep(1000);
// Back to black color
driver.navigate().back();
Thread.sleep(1000);
// Changes the text to proverbial
driver.findElement(MobileBy.id("Text")).click();
Thread.sleep(1000);
// toast is visible
driver.findElement(MobileBy.id("toast")).click();
Thread.sleep(1000);
// notification is visible
driver.findElement(MobileBy.id("notification")).click();
Thread.sleep(2000);
// Open the geolocation page
driver.findElement(MobileBy.id("geoLocation")).click();
Thread.sleep(4000);
driver.navigate().back();
Thread.sleep(1000);
// Takes to speed test page
driver.findElement(MobileBy.id("speedTest")).click();
Thread.sleep(5000);
driver.navigate().back();
Thread.sleep(1000);
// Opens the browser
MobileElement browser = (MobileElement) driver.findElementByAccessibilityId("Browser");
browser.click();
Thread.sleep(3000);
WebDriverWait el7 = new WebDriverWait(driver, 30);
el7.until(ExpectedConditions.elementToBeClickable(MobileBy.id("url")));
driver.findElementById("url").sendKeys("https://www.lambdatest.com/");
// Clicks on the text box
WebDriverWait el = new WebDriverWait(driver, 90);
MobileElement el4 = (MobileElement) driver.findElementByAccessibilityId("find");
el.until(ExpectedConditions.elementToBeClickable(el4));
el4.click();
el4.sendKeys("Lambdatest");
// ((JavascriptExecutor) driver).executeScript("lambda-status=passed");
driver.quit();
} catch (Exception t) {
System.out.println(t);
driver.quit();
}
}
}