Web Driver for Android

Document created by DPM Admin Employee on Jul 18, 2017Last modified by Trishala Kalal on Aug 10, 2017
Version 2Show Document
  • View in full screen mode

 Java Custom Modules allow you to use selenium chrome driver to interact with any web view. 

Required Downloads




  • Enable Custom Modules and Disable Java Security Manager in device license. 

  • For local use: The chrome web driver executable must be in the path or a system property must be set "System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");".

  • For remote use: Use RemoteWebDriver and have it point to the IP Address and port number of the machine currently running the chrome web driver exectuable. The chrome web driver exectuable must then be started with to allow remote connections from certain IP's (or if you omit the IP addresses, all remote connections are accepted.)

  • The device must be Android 4.4 or higher, with WebView.setWebContentsDebuggingEnabled(true); and javascript enabled. 

  • The device needs to be connected to adb (via USB or tcp/ip).

To build a web driver test


  1. Find the package and activity hosting the web view.

    • Package: Run aapt against the apk: /Users/username/Documents/android-sdk-macosx/build-tools/22.0.1/aapt dump badging com.app-package.apk | grep package.

    • Activity: Use a tool called apktool to decode the apk and read the Android manifest file. There is usually multiple activities, which will require trial and error to choose the correct activity.
  1. Create a Java project and add the two selenium jars downloaded earlier as external jars.
  1. In the app, navigate to the page to be tested. In chrome, go to chrome://inspect

  1. WebDriver has several commands and methods to interact with a webview, like performing simple actions like type or click. To do this, a handle on the HTML element must be obtained. Use the WebDriver.findElement()to find elements by id, class name, tag name, and etc. Once you get the WebElement, you can perform actions like click or sendKeys to it.

  1. Once your web driver test is code complete, export the package(s) that are necessary to run the web driver function.



  1. Create a Custom Module in CloudTest and upload the JAR.
  1. Create a custom script and add the recently added custom module JAR to it. Invoke the test method to run the web driver test.