Skip to main content

ChromeDriver on Android

If you wish to test web applications using Chrome on Android, you can initialize the driver as ChromeDriver. What this means is that commands and actions will be carried out by ChromeDriver, allows for more accurate and error-free web application tests. The implementation of ChromeDriver takes into account testing outside the web application. In case you change the context from Web to Native App, commands will be delegated through Appium Driver; if you switch back to Web context, commands will once more be delegated to ChromeDriver.

To initialize ChromeDriver, you need to set it in the test capabilities:

Java

dc.setBrowserName(MobileBrowserType.CHROME);

Python

self.dc['browserName'] = 'chrome'

C Sharp

dc.SetCapability(MobileCapabilityType.BrowserName, MobileBrowserType.Chrome);
info

Replace <server> with the appropriate URL.

Ruby

desired_caps = {
caps: {
...
browserName: 'chrome',
...
},
appium_lib: {
server_url: '<server>',
}
}
info

Setting this capability will cause Chrome browser to launch immediately once the test starts. It is not possible to set this capability alongside app related capabilities (AndroidMobileCapabilityType.APP_PACKAGE, AndroidMobileCapabilityType.APP_ACTIVITY) because the MobileBrowserType capability takes precedence. The corresponding context is "CHROMIUM". If you want to switch to Native app context and back, you need to set the context to "CHROMIUM":

Java

driver.context("CHROMIUM");


Python

self.driver.switch_to.context("CHROMIUM")


C Sharp

driver.Context = "CHROMIUM";

Ruby

@driver.switch_to.context("CHROMIUM")