Search in sources :

Example 1 with LocalAppiumLauncher

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

the class TestLocalAppiumLauncher method testAppiumRandomPort.

@Test(groups = { "ut" })
public void testAppiumRandomPort() throws IOException {
    initValidAppiumInstallation();
    initValidNodeInstallation();
    LocalAppiumLauncher appium1 = new LocalAppiumLauncher();
    LocalAppiumLauncher appium2 = new LocalAppiumLauncher();
    Assert.assertNotEquals(appium1.getAppiumPort(), appium2.getAppiumPort());
}
Also used : LocalAppiumLauncher(com.seleniumtests.browserfactory.mobile.LocalAppiumLauncher) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with LocalAppiumLauncher

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

the class TestLocalAppiumLauncher method testAppiumStartup.

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

Example 3 with LocalAppiumLauncher

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

the class TestWebUiDriver method testLocalAndroidDriver.

@Test(groups = { "it" })
public void testLocalAndroidDriver() throws Exception {
    whenNew(AdbWrapper.class).withNoArguments().thenReturn(adbWrapper);
    List<MobileDevice> deviceList = new ArrayList<>();
    deviceList.add(new MobileDevice("IPhone 6", "0000", "ios", "10.2", new ArrayList<>()));
    deviceList.add(new MobileDevice("Nexus 5", "1234", "android", "5.0", new ArrayList<>()));
    deviceList.add(new MobileDevice("Nexus 7", "1235", "android", "6.0", 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().setPlatform("android");
    SeleniumTestsContextManager.getThreadContext().setMobilePlatformVersion("5.0");
    SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APPIUM_APP_ANDROID);
    PowerMockito.mockStatic(AppiumLauncherFactory.class);
    LocalAppiumLauncher appiumLauncher;
    try {
        appiumLauncher = spy(new LocalAppiumLauncher());
        when(AppiumLauncherFactory.getInstance()).thenReturn(appiumLauncher);
        WebUIDriver.getWebDriver(true);
    } catch (ConfigurationException e) {
        throw new SkipException("Test skipped, appium not correctly configured", e);
    }
    PowerMockito.verifyNew(AndroidDriver.class).withArguments(any(URL.class), any(Capabilities.class));
    verify(appiumLauncher).stopAppium();
}
Also used : MobileDevice(com.seleniumtests.browserfactory.mobile.MobileDevice) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) Capabilities(org.openqa.selenium.Capabilities) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ArrayList(java.util.ArrayList) LocalAppiumLauncher(com.seleniumtests.browserfactory.mobile.LocalAppiumLauncher) SkipException(org.testng.SkipException) 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 LocalAppiumLauncher

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

the class TestLocalAppiumLauncher method testAppiumFound.

/**
 * Test when appium_home exist, version found
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testAppiumFound() throws IOException {
    initValidAppiumInstallation();
    initValidNodeInstallation();
    LocalAppiumLauncher appium = new LocalAppiumLauncher();
    Assert.assertEquals(appium.getAppiumVersion(), "1.4.13");
}
Also used : LocalAppiumLauncher(com.seleniumtests.browserfactory.mobile.LocalAppiumLauncher) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with LocalAppiumLauncher

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

the class TestLocalAppiumLauncher method testNodeFoundInAppiumPath.

/**
 * !!! THIS METHOD is ignored as PowerMock cannot mock nio.Paths class !!!
 *
 * Test when node is found in appium path
 * @throws IOException
 */
@Test(groups = { "ut" }, enabled = false)
public void testNodeFoundInAppiumPath() throws IOException {
    initValidAppiumInstallation();
    PowerMockito.mockStatic(OSCommand.class);
    when(OSCommand.executeCommandAndWait("/opt/appium/node -v")).thenReturn("v6.2.1");
    PowerMockito.mockStatic(Paths.class);
    when(Paths.get("/opt/appium/", "node")).thenReturn(nodePath);
    when(nodePath.toFile()).thenReturn(nodeFile);
    when(nodeFile.exists()).thenReturn(true);
    LocalAppiumLauncher appium = new LocalAppiumLauncher();
    Assert.assertEquals(appium.getNodeVersion(), "v6.2.1");
}
Also used : LocalAppiumLauncher(com.seleniumtests.browserfactory.mobile.LocalAppiumLauncher) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

LocalAppiumLauncher (com.seleniumtests.browserfactory.mobile.LocalAppiumLauncher)10 Test (org.testng.annotations.Test)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 MockitoTest (com.seleniumtests.MockitoTest)8 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)2 SkipException (org.testng.SkipException)2 GenericDriverTest (com.seleniumtests.GenericDriverTest)1 GenericTest (com.seleniumtests.GenericTest)1 MobileDevice (com.seleniumtests.browserfactory.mobile.MobileDevice)1 ReporterTest (com.seleniumtests.it.reporter.ReporterTest)1 AndroidDriver (io.appium.java_client.android.AndroidDriver)1 File (java.io.File)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Capabilities (org.openqa.selenium.Capabilities)1 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)1