use of io.appium.java_client.ios.IOSDriver in project java-client by appium.
the class StartingAppLocallyTest method startingIOSAppWithCapabilitiesAndFlagsOnServerSideTest.
@Test
public void startingIOSAppWithCapabilitiesAndFlagsOnServerSideTest() {
DesiredCapabilities serverCapabilities = new DesiredCapabilities();
serverCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
serverCapabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, // some environment is too slow
500000);
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.2");
File appDir = new File("src/test/java/io/appium/java_client");
File app = new File(appDir, "UICatalog.app.zip");
DesiredCapabilities clientCapabilities = new DesiredCapabilities();
clientCapabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
AppiumServiceBuilder builder = new AppiumServiceBuilder().withArgument(GeneralServerFlag.SESSION_OVERRIDE).withArgument(GeneralServerFlag.STRICT_CAPS).withCapabilities(serverCapabilities);
IOSDriver<?> driver = new IOSDriver<>(builder, clientCapabilities);
try {
Capabilities caps = driver.getCapabilities();
assertEquals(true, caps.getCapability(MobileCapabilityType.PLATFORM_NAME).equals(MobilePlatform.IOS));
assertNotEquals(null, caps.getCapability(MobileCapabilityType.DEVICE_NAME));
} finally {
driver.quit();
}
}
use of io.appium.java_client.ios.IOSDriver in project opentest by mcdcorp.
the class AppiumHelper method createDriver.
private static AppiumDriver<MobileElement> createDriver(String url, Map<String, Object> capsMap) {
if (url == null) {
url = AppiumHelper.getConfig().getString("appium.appiumServerUrl", "http://127.0.0.1:4723/wd/hub");
}
Logger.info(String.format("Using Appium server URL \"%s\"", url));
if (capsMap == null) {
capsMap = new HashMap<String, Object>();
}
String platformLowercase = getCapabilityAsString(capsMap, "platformName", getCapabilityAsString(capsMap, "platform", config.getString("appium.desiredCapabilities.platformName", null)));
if (platformLowercase != null) {
platformLowercase = platformLowercase.trim().toLowerCase();
} else {
throw new RuntimeException("The \"platformName\" capability was not populated in " + "configuration. Please provide a value for it in the " + "\"appium.desiredCapabilities.platformName\" key. The valid " + "values are \"iOS\" or \"Android\".");
}
AppiumHelper.platform = platformLowercase;
AppiumDriver<MobileElement> newDriver;
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(CapabilityType.BROWSER_NAME, "");
caps.setCapability("newCommandTimeout", 600);
injectCapsFromConfig(caps);
try {
if (platform.equalsIgnoreCase("android")) {
caps.setCapability("deviceName", "Android Emulator");
caps.setCapability("platformName", "Android");
copyCapabilities(capsMap, caps);
Logger.info("Creating Appium Android driver...");
newDriver = new AndroidDriver<>(new URL(url), caps);
} else if (platform.equalsIgnoreCase("ios")) {
caps.setCapability("deviceName", "iOS Emulator");
caps.setCapability("platformName", "iOS");
copyCapabilities(capsMap, caps);
Logger.info("Creating Appium iOS driver...");
newDriver = new IOSDriver<>(new URL(url), caps);
} else {
throw new RuntimeException("Failed to instantiate Appium driver. The \"platformName\" " + "capability is missing or is specified incorrectly. The valid " + "values are \"iOS\" or \"Android\".");
}
} catch (MalformedURLException ex) {
throw new RuntimeException("Failed to initialize Appium", ex);
}
return newDriver;
}
Aggregations