use of com.seleniumtests.browserfactory.mobile.MobileDevice 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();
}
}
use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.
the class TestMobileDeviceSelector method testCapabilitiesUpdate.
/**
* Test the update of capabilities with device properties
* input capabilities only know the name, and from that data, we expect to get the platform and version
* plus an updated version of device name with the id instead as it's the property expected by ADB to
* communicate with any device
*/
@Test(groups = { "ut" })
public void testCapabilitiesUpdate() {
// available devices
List<MobileDevice> deviceList = new ArrayList<>();
deviceList.add(new MobileDevice("nexus 5", "1234", "android", "5.0", new ArrayList<>()));
when(adbWrapper.getDeviceList()).thenReturn(deviceList);
DesiredCapabilities requestedCaps = new DesiredCapabilities();
requestedCaps.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus 5");
deviceSelector.setAndroidReady(true);
deviceSelector.setIosReady(false);
MutableCapabilities updatedCaps = deviceSelector.updateCapabilitiesWithSelectedDevice(requestedCaps, DriverMode.LOCAL);
Assert.assertEquals(updatedCaps.getCapability(MobileCapabilityType.PLATFORM_NAME), "android");
Assert.assertEquals(updatedCaps.getCapability(MobileCapabilityType.DEVICE_NAME), "1234");
Assert.assertEquals(updatedCaps.getCapability(MobileCapabilityType.PLATFORM_VERSION), "5.0");
Assert.assertNull(updatedCaps.getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE));
}
use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.
the class TestMobileDeviceSelector method testSelectMostMatchingAndroidDevice.
/**
* Test that only the device that matches all capabilities is selected
*/
@Test(groups = { "ut" })
public void testSelectMostMatchingAndroidDevice() {
// available devices
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);
// requested caps
DesiredCapabilities requestedCaps = new DesiredCapabilities();
requestedCaps.setCapability(MobileCapabilityType.PLATFORM_NAME, "android");
requestedCaps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0");
deviceSelector.setAndroidReady(true);
deviceSelector.setIosReady(false);
Assert.assertEquals(deviceSelector.getRelevantMobileDevice(requestedCaps), deviceList.get(2));
}
use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.
the class TestMobileDeviceSelector method testSelectFirstMatchingiOSDevice.
/**
* 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 testSelectFirstMatchingiOSDevice() {
// 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<>()));
deviceListIos.add(new MobileDevice("IPhone 7", "0000", "iOS", "10.3", new ArrayList<>()));
when(instrumentsWrapper.parseIosDevices()).thenReturn(deviceListIos);
// requested caps
DesiredCapabilities requestedCaps = new DesiredCapabilities();
requestedCaps.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
deviceSelector.setAndroidReady(true);
deviceSelector.setIosReady(true);
Assert.assertEquals(deviceSelector.getRelevantMobileDevice(requestedCaps), deviceListIos.get(0));
}
use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.
the class TestMobileDeviceSelector method testCapabilitiesUpdateWithDriver.
/**
* Test the update of driver capabilities when using browsers in local mode
*/
@Test(groups = { "ut" })
public void testCapabilitiesUpdateWithDriver() {
// available devices
List<MobileDevice> deviceList = new ArrayList<>();
BrowserInfo chromeInfo = new BrowserInfo(BrowserType.CHROME, "47.0", null);
chromeInfo.setDriverFileName("chromedriver.exe");
deviceList.add(new MobileDevice("nexus 5", "1234", "android", "5.0", Arrays.asList(chromeInfo)));
when(adbWrapper.getDeviceList()).thenReturn(deviceList);
DesiredCapabilities requestedCaps = new DesiredCapabilities();
requestedCaps.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus 5");
requestedCaps.setCapability(MobileCapabilityType.BROWSER_NAME, "chrome");
deviceSelector.setAndroidReady(true);
deviceSelector.setIosReady(false);
MutableCapabilities updatedCaps = deviceSelector.updateCapabilitiesWithSelectedDevice(requestedCaps, DriverMode.LOCAL);
Assert.assertEquals(updatedCaps.getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE), "chromedriver.exe");
}
Aggregations