Dual WebDriver and AppiumDriver testing

There is not that much difference when creating a WebDriver and AppiumDriver simultaneously, except that you have to deal with more setup/teardown on the mobile side of things.

Creating the drivers is relatively similar. Switching between the drivers is also similar. The WebDriver and AppiumDriver setup/teardown is different, and so are the API methods for each. With mobile devices, the application is usually installed in setup and uninstalled in teardown before quitting. That's pretty much it!

Let's take a quick look at an example:

@Test
public void tc002_multiWebMobileDriver(String rowID,
String description)
throws Exception {

// create the WebDriver instance
CreateDriver.getInstance().setDriver("chrome",
Global_VARS.DEF_ENVIRONMENT,
Global_VARS.DEF_PLATFORM);

// save the WebDriver instance
WebDriver chromeDriver = CreateDriver.getInstance().getDriver();

// create the MobileDriver instance, passing in device name
Map<String, Object> preferences = new HashMap<String, Object>();
preferences.put("deviceName", "iPhone 6 Simulator");

CreateDriver.getInstance().setDriver("iphone",
Global_VARS.DEF_ENVIRONMENT,
Global_VARS.DEF_PLATFORM,
preferences);

// save the MobileDriver instance
AppiumDriver<MobileElement> mobileDriver =
CreateDriver.getInstance().getDriver(true);

// switch back to the chrome driver
CreateDriver.getInstance().setDriver(chromeDriver);
// perform some actions on the WebDriver classes

// switch back to the mobile driver
CreateDriver.getInstance().setDriver(mobileDriver);
// perform some actions on the MobileDriver classes

// switch back to chrome and quit driver
CreateDriver.getInstance().setDriver(chromeDriver);
chromeDriver.quit();

// switch back to iphone and quit that driver
CreateDriver.getInstance().setDriver(mobileDriver);
mobileDriver.quit();
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.112.1