Reputation: 51
I would like to be able to do testing using chromedriver on Android device. How is it possible?
I have rooted an Android device and cannot get the Chrome tests to work.
I tried to follow this guide: https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android
I cannot find which Chromedriver version I should install on Android device.
Does anyone have an example or step by step guide for this?
Upvotes: 4
Views: 13596
Reputation: 11
For me, the previous answer works but with Chrome version 66 and chrome driver 37.
System.setProperty("webdriver.chrome.driver", "<path_to_your_chrome_binary>");
Even if system property is "webdriver.chrome.driver
", you have to set the path of chrome on the device like "/data/app/com.android.chrome-1.apk
"
Upvotes: 1
Reputation: 211
You don't need to install chromedriver on a phone, only your local machine you want to run tests from. I actually set this up couple weeks ago. This is basic set up you need:
public WebDriver getMobileChromeDriver() {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("androidPackage", "com.android.chrome");
chromeOptions.setExperimentalOption("androidDeviceSerial", deviceId);
return new ChromeDriver(chromeOptions);
}
deviceId variable contains uuid taken from adb for particular device. If you don't provide it chromedriver will run on first available node.
One more thing you need to do before running tests is start adb server.
On linux based machines it would be something like: adb start-server (assuming you have adb in your path)
If you have problem with determining which chromedriver you need for your local machine let me know.
If you are using Windows machine you probably need to add one more line of code to point to your chrome binary:
System.setProperty("webdriver.chrome.driver", "<path_to_your_chrome_binary>");
Upvotes: 4