forked from saucelabs-training/demo-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIOSNativeAppExample.java
66 lines (57 loc) · 2.23 KB
/
IOSNativeAppExample.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
package com.emusim;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.ios.IOSDriver;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.openqa.selenium.By;
import org.openqa.selenium.MutableCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
import static org.junit.Assert.assertTrue;
public class IOSNativeAppExample {
@Rule
public TestName name = new TestName() {
public String getMethodName() {
return String.format("%s", super.getMethodName());
}
};
private AppiumDriver<MobileElement> driver;
public AppiumDriver<MobileElement> getDriver() {
return driver;
}
@Before
public void setUp() throws MalformedURLException {
MutableCapabilities capabilities = new MutableCapabilities();
capabilities.setCapability("appiumVersion", "1.17.1");
capabilities.setCapability("idleTimeout", "90");
capabilities.setCapability("noReset", "true");
capabilities.setCapability("newCommandTimeout", "90");
capabilities.setCapability("language", "en");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "13.2");
capabilities.setCapability("deviceName", "iPhone 11 Pro Max");
capabilities.setCapability("name", name.getMethodName());
//You need to upload your own Native Mobile App to Sauce Storage!
//https://wiki.saucelabs.com/display/DOCS/Uploading+your+Application+to+Sauce+Storage
capabilities.setCapability("app", "sauce-storage:sample-app-ios-7-21-20.zip");
driver = new IOSDriver(
new URL("https://" + System.getenv("SAUCE_USERNAME") + ":" +
System.getenv("SAUCE_ACCESS_KEY") +
"@ondemand.saucelabs.com:443" + "/wd/hub"),
capabilities);
}
@After
public void tearDown() {
if (getDriver() != null) {
getDriver().quit();
}
}
@Test
public void shouldOpenApp() {
assertTrue(getDriver().findElement(By.id("test-LOGIN")).isDisplayed());
}
}