use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.
the class TestMobileDeviceSelector method testSelectFirstMatchingAndroidDevice.
/**
* Test that when several devices exists with the same capabilities, the first one is selected
* Test platform name with different cases
*/
@Test(groups = { "ut" })
public void testSelectFirstMatchingAndroidDevice() {
// available devices
List<MobileDevice> deviceListAndroid = new ArrayList<>();
deviceListAndroid.add(new MobileDevice("Nexus 5", "1234", "Android", "5.0", new ArrayList<>()));
deviceListAndroid.add(new MobileDevice("Nexus 7", "1235", "Android", "6.0", new ArrayList<>()));
when(adbWrapper.getDeviceList()).thenReturn(deviceListAndroid);
List<MobileDevice> deviceListIos = new ArrayList<>();
deviceListIos.add(new MobileDevice("IPhone 6", "0000", "iOS", "10.2", new ArrayList<>()));
when(instrumentsWrapper.parseIosDevices()).thenReturn(deviceListIos);
// requested caps
DesiredCapabilities requestedCaps = new DesiredCapabilities();
requestedCaps.setCapability(MobileCapabilityType.PLATFORM_NAME, "android");
deviceSelector.setAndroidReady(true);
deviceSelector.setIosReady(true);
Assert.assertEquals(deviceSelector.getRelevantMobileDevice(requestedCaps), deviceListAndroid.get(0));
}
use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.
the class TestMobileDeviceSelector method testSelectNonExistingAndroidDevice.
/**
* Test that an error is raised when no matching device is found
*/
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testSelectNonExistingAndroidDevice() {
// available devices
List<MobileDevice> deviceList = new ArrayList<>();
when(adbWrapper.getDeviceList()).thenReturn(deviceList);
// requested caps
DesiredCapabilities requestedCaps = new DesiredCapabilities();
requestedCaps.setCapability(MobileCapabilityType.PLATFORM_NAME, "android");
deviceSelector.setAndroidReady(true);
deviceSelector.setIosReady(false);
deviceSelector.getRelevantMobileDevice(requestedCaps);
}
use of com.seleniumtests.browserfactory.mobile.MobileDevice 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();
}
use of com.seleniumtests.browserfactory.mobile.MobileDevice 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();
}
use of com.seleniumtests.browserfactory.mobile.MobileDevice 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();
}
Aggregations