Search in sources :

Example 6 with IOSDriver

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();
    }
}
Also used : IOSDriver(io.appium.java_client.ios.IOSDriver) Capabilities(org.openqa.selenium.Capabilities) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) AppiumServiceBuilder(io.appium.java_client.service.local.AppiumServiceBuilder) File(java.io.File) Test(org.junit.Test)

Example 7 with IOSDriver

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;
}
Also used : IOSDriver(io.appium.java_client.ios.IOSDriver) MalformedURLException(java.net.MalformedURLException) MobileElement(io.appium.java_client.MobileElement) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) URL(java.net.URL)

Aggregations

IOSDriver (io.appium.java_client.ios.IOSDriver)7 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)6 URL (java.net.URL)4 File (java.io.File)3 MalformedURLException (java.net.MalformedURLException)3 Test (org.junit.Test)3 Capabilities (org.openqa.selenium.Capabilities)3 AppiumServiceBuilder (io.appium.java_client.service.local.AppiumServiceBuilder)2 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)2 RemoteDevice (com.qaprosoft.carina.commons.models.RemoteDevice)1 Device (com.qaprosoft.carina.core.foundation.webdriver.device.Device)1 AppiumDriver (io.appium.java_client.AppiumDriver)1 MobileElement (io.appium.java_client.MobileElement)1 AndroidDriver (io.appium.java_client.android.AndroidDriver)1 AndroidElement (io.appium.java_client.android.AndroidElement)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HttpHost (org.apache.http.HttpHost)1 AuthScope (org.apache.http.auth.AuthScope)1 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)1