Search in sources :

Example 1 with ExistingAppiumLauncher

use of com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher in project seleniumRobot by bhecquet.

the class TestExistingAppiumLauncher method testAppiumStartup.

@Test(groups = { "it" }, enabled = false)
public void testAppiumStartup() {
    try {
        ExistingAppiumLauncher appium = new ExistingAppiumLauncher("http://localhost:4723/wd/hub/");
        appium.startAppium();
        appium.stopAppium();
    } catch (ConfigurationException e) {
        throw new SkipException("Test skipped, appium not correctly configured", e);
    }
}
Also used : ExistingAppiumLauncher(com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) SkipException(org.testng.SkipException) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 2 with ExistingAppiumLauncher

use of com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher in project seleniumRobot by bhecquet.

the class TestWebUiDriver method testLocaliOSDriverWithRemoteAppiumServer.

@Test(groups = { "it" })
public void testLocaliOSDriverWithRemoteAppiumServer() throws Exception {
    whenNew(InstrumentsWrapper.class).withNoArguments().thenReturn(instrumentsWrapper);
    List<MobileDevice> deviceList = new ArrayList<>();
    when(instrumentsWrapper.parseIosDevices()).thenReturn(deviceList);
    whenNew(IOSDriver.class).withAnyArguments().thenReturn(iosDriver);
    when(iosDriver.manage()).thenReturn(driverOptions);
    when(iosDriver.getCapabilities()).thenReturn(DesiredCapabilities.chrome());
    when(driverOptions.timeouts()).thenReturn(timeouts);
    SeleniumTestsContextManager.getThreadContext().setRunMode("local");
    SeleniumTestsContextManager.getThreadContext().setAppiumServerUrl("http://localhost:4321/wd/hub/");
    SeleniumTestsContextManager.getThreadContext().setDeviceId("123456");
    SeleniumTestsContextManager.getThreadContext().setPlatform("ios");
    SeleniumTestsContextManager.getThreadContext().setMobilePlatformVersion("13.0");
    SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APPIUM_APP_IOS);
    createServerMock("GET", "/wd/hub/sessions", 200, "{}");
    PowerMockito.mockStatic(AppiumLauncherFactory.class);
    ExistingAppiumLauncher appiumLauncher;
    appiumLauncher = spy(new ExistingAppiumLauncher("http://localhost:4321/wd/hub/"));
    when(AppiumLauncherFactory.getInstance()).thenReturn(appiumLauncher);
    WebUIDriver.getWebDriver(true);
    PowerMockito.verifyNew(IOSDriver.class).withArguments(any(URL.class), any(Capabilities.class));
    WebUIDriver.cleanUp();
    verify(appiumLauncher).stopAppium();
}
Also used : ExistingAppiumLauncher(com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher) IOSDriver(io.appium.java_client.ios.IOSDriver) MobileDevice(com.seleniumtests.browserfactory.mobile.MobileDevice) Capabilities(org.openqa.selenium.Capabilities) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ArrayList(java.util.ArrayList) URL(java.net.URL) Test(org.testng.annotations.Test) GenericDriverTest(com.seleniumtests.GenericDriverTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) ReporterTest(com.seleniumtests.it.reporter.ReporterTest)

Example 3 with ExistingAppiumLauncher

use of com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher in project seleniumRobot by bhecquet.

the class TestWebUiDriver method testLocalAndroidDriverWithRemoteAppiumServer.

/**
 * Test we can connect to a remote appium server (no local devices)
 * @throws Exception
 */
@Test(groups = { "it" })
public void testLocalAndroidDriverWithRemoteAppiumServer() throws Exception {
    whenNew(AdbWrapper.class).withNoArguments().thenReturn(adbWrapper);
    List<MobileDevice> deviceList = new ArrayList<>();
    when(adbWrapper.getDeviceList()).thenReturn(deviceList);
    whenNew(AndroidDriver.class).withAnyArguments().thenReturn(androidDriver);
    when(androidDriver.manage()).thenReturn(driverOptions);
    when(androidDriver.getCapabilities()).thenReturn(DesiredCapabilities.chrome());
    when(driverOptions.timeouts()).thenReturn(timeouts);
    SeleniumTestsContextManager.getThreadContext().setRunMode("local");
    SeleniumTestsContextManager.getThreadContext().setAppiumServerUrl("http://localhost:4321/wd/hub/");
    SeleniumTestsContextManager.getThreadContext().setDeviceId("emulator-5556");
    SeleniumTestsContextManager.getThreadContext().setPlatform("android");
    SeleniumTestsContextManager.getThreadContext().setMobilePlatformVersion("5.0");
    SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APPIUM_APP_ANDROID);
    createServerMock("GET", "/wd/hub/sessions", 200, "{}");
    PowerMockito.mockStatic(AppiumLauncherFactory.class);
    ExistingAppiumLauncher appiumLauncher;
    appiumLauncher = spy(new ExistingAppiumLauncher("http://localhost:4321/wd/hub/"));
    when(AppiumLauncherFactory.getInstance()).thenReturn(appiumLauncher);
    WebUIDriver.getWebDriver(true);
    PowerMockito.verifyNew(AndroidDriver.class).withArguments(any(URL.class), any(Capabilities.class));
    WebUIDriver.cleanUp();
    verify(appiumLauncher).stopAppium();
}
Also used : ExistingAppiumLauncher(com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher) MobileDevice(com.seleniumtests.browserfactory.mobile.MobileDevice) Capabilities(org.openqa.selenium.Capabilities) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ArrayList(java.util.ArrayList) AndroidDriver(io.appium.java_client.android.AndroidDriver) URL(java.net.URL) Test(org.testng.annotations.Test) GenericDriverTest(com.seleniumtests.GenericDriverTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) ReporterTest(com.seleniumtests.it.reporter.ReporterTest)

Example 4 with ExistingAppiumLauncher

use of com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher in project seleniumRobot by bhecquet.

the class TestWebUiDriver method testLocalAndroidDriverWithRemoteAppiumServerAndNoDeviceId.

/**
 * Test we get an error when using remote appium and no deviceId is provided
 * @throws Exception
 */
@Test(groups = { "it" }, expectedExceptions = ConfigurationException.class)
public void testLocalAndroidDriverWithRemoteAppiumServerAndNoDeviceId() throws Exception {
    try {
        whenNew(AdbWrapper.class).withNoArguments().thenReturn(adbWrapper);
        List<MobileDevice> deviceList = new ArrayList<>();
        when(adbWrapper.getDeviceList()).thenReturn(deviceList);
        whenNew(AndroidDriver.class).withAnyArguments().thenReturn(androidDriver);
        when(androidDriver.manage()).thenReturn(driverOptions);
        when(androidDriver.getCapabilities()).thenReturn(DesiredCapabilities.chrome());
        when(driverOptions.timeouts()).thenReturn(timeouts);
        SeleniumTestsContextManager.getThreadContext().setRunMode("local");
        SeleniumTestsContextManager.getThreadContext().setAppiumServerUrl("http://localhost:4321/wd/hub/");
        SeleniumTestsContextManager.getThreadContext().setPlatform("android");
        SeleniumTestsContextManager.getThreadContext().setMobilePlatformVersion("5.0");
        SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APPIUM_APP_ANDROID);
        createServerMock("GET", "/wd/hub/sessions", 200, "{}");
        PowerMockito.mockStatic(AppiumLauncherFactory.class);
        ExistingAppiumLauncher appiumLauncher;
        appiumLauncher = spy(new ExistingAppiumLauncher("http://localhost:4321/wd/hub/"));
        when(AppiumLauncherFactory.getInstance()).thenReturn(appiumLauncher);
        WebUIDriver.getWebDriver(true);
    } finally {
        WebUIDriver.cleanUp();
    }
}
Also used : ExistingAppiumLauncher(com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher) MobileDevice(com.seleniumtests.browserfactory.mobile.MobileDevice) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test) GenericDriverTest(com.seleniumtests.GenericDriverTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) ReporterTest(com.seleniumtests.it.reporter.ReporterTest)

Aggregations

ExistingAppiumLauncher (com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher)4 Test (org.testng.annotations.Test)4 GenericDriverTest (com.seleniumtests.GenericDriverTest)3 MobileDevice (com.seleniumtests.browserfactory.mobile.MobileDevice)3 ReporterTest (com.seleniumtests.it.reporter.ReporterTest)3 ArrayList (java.util.ArrayList)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 URL (java.net.URL)2 Capabilities (org.openqa.selenium.Capabilities)2 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)2 GenericTest (com.seleniumtests.GenericTest)1 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 AndroidDriver (io.appium.java_client.android.AndroidDriver)1 IOSDriver (io.appium.java_client.ios.IOSDriver)1 SkipException (org.testng.SkipException)1