Search in sources :

Example 1 with AppiumServiceBuilder

use of io.appium.java_client.service.local.AppiumServiceBuilder in project java-client by appium.

the class StartingAppLocallyTest method startingIOSAppWithCapabilitiesAndServiseTest.

@Test
public void startingIOSAppWithCapabilitiesAndServiseTest() {
    File appDir = new File("src/test/java/io/appium/java_client");
    File app = new File(appDir, "UICatalog.app.zip");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.APPIUM);
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.2");
    // sometimes environment has performance problems
    capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000);
    AppiumServiceBuilder builder = new AppiumServiceBuilder().withArgument(GeneralServerFlag.SESSION_OVERRIDE).withArgument(GeneralServerFlag.STRICT_CAPS);
    IOSDriver<?> driver = new IOSDriver<>(builder, capabilities);
    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 2 with AppiumServiceBuilder

use of io.appium.java_client.service.local.AppiumServiceBuilder in project java-client by appium.

the class SelendroidModeTest method beforeClass.

/**
 * initialization.
 */
@BeforeClass
public static void beforeClass() {
    AppiumServiceBuilder builder = new AppiumServiceBuilder();
    service = builder.build();
    service.start();
    File appDir = new File("src/test/java/io/appium/java_client");
    File app = new File(appDir, "ApiDemos-debug.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    capabilities.setCapability(AndroidMobileCapabilityType.SELENDROID_PORT, SELENDROID_PORT);
    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.SELENDROID);
    driver = new AndroidDriver<>(service.getUrl(), capabilities);
    driver.context("NATIVE_APP");
}
Also used : AppiumServiceBuilder(io.appium.java_client.service.local.AppiumServiceBuilder) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 3 with AppiumServiceBuilder

use of io.appium.java_client.service.local.AppiumServiceBuilder in project java-client by appium.

the class StartingAppLocallyTest method startingAndroidAppWithCapabilitiesAndServiceTest.

@Test
public void startingAndroidAppWithCapabilitiesAndServiceTest() {
    File appDir = new File("src/test/java/io/appium/java_client");
    File app = new File(appDir, "ApiDemos-debug.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    AppiumServiceBuilder builder = new AppiumServiceBuilder().withArgument(GeneralServerFlag.SESSION_OVERRIDE).withArgument(GeneralServerFlag.STRICT_CAPS);
    AndroidDriver<?> driver = new AndroidDriver<>(builder, capabilities);
    try {
        Capabilities caps = driver.getCapabilities();
        assertEquals(true, caps.getCapability(MobileCapabilityType.PLATFORM_NAME).equals(MobilePlatform.ANDROID));
        assertNotEquals(null, caps.getCapability(MobileCapabilityType.DEVICE_NAME));
    } finally {
        driver.quit();
    }
}
Also used : 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) AndroidDriver(io.appium.java_client.android.AndroidDriver) File(java.io.File) Test(org.junit.Test)

Example 4 with AppiumServiceBuilder

use of io.appium.java_client.service.local.AppiumServiceBuilder 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 5 with AppiumServiceBuilder

use of io.appium.java_client.service.local.AppiumServiceBuilder in project java-client by appium.

the class StartingAppLocallyTest method startingAndroidAppWithCapabilitiesAndFlagsOnServerSideTest.

@Test
public void startingAndroidAppWithCapabilitiesAndFlagsOnServerSideTest() {
    File appDir = new File("src/test/java/io/appium/java_client");
    File app = new File(appDir, "ApiDemos-debug.apk");
    File chrome = getChromeDriver();
    DesiredCapabilities serverCapabilities = new DesiredCapabilities();
    serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
    serverCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
    serverCapabilities.setCapability(MobileCapabilityType.FULL_RESET, true);
    serverCapabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);
    serverCapabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    serverCapabilities.setCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE, chrome.getAbsolutePath());
    AppiumServiceBuilder builder = new AppiumServiceBuilder().withArgument(GeneralServerFlag.SESSION_OVERRIDE).withArgument(GeneralServerFlag.STRICT_CAPS).withCapabilities(serverCapabilities);
    DesiredCapabilities clientCapabilities = new DesiredCapabilities();
    clientCapabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "io.appium.android.apis");
    clientCapabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, ".view.WebView1");
    AndroidDriver<?> driver = new AndroidDriver<>(builder, clientCapabilities);
    try {
        Capabilities caps = driver.getCapabilities();
        assertEquals(true, caps.getCapability(MobileCapabilityType.PLATFORM_NAME).equals(MobilePlatform.ANDROID));
        assertNotEquals(null, caps.getCapability(MobileCapabilityType.DEVICE_NAME));
    } finally {
        driver.quit();
    }
}
Also used : 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) AndroidDriver(io.appium.java_client.android.AndroidDriver) File(java.io.File) Test(org.junit.Test)

Aggregations

AppiumServiceBuilder (io.appium.java_client.service.local.AppiumServiceBuilder)6 File (java.io.File)5 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)5 Test (org.junit.Test)4 Capabilities (org.openqa.selenium.Capabilities)4 AndroidDriver (io.appium.java_client.android.AndroidDriver)2 IOSDriver (io.appium.java_client.ios.IOSDriver)2 BeforeClass (org.junit.BeforeClass)1