Skip to content

Instantly share code, notes, and snippets.

@juanpicado
Last active April 6, 2017 09:21
Show Gist options
  • Save juanpicado/2f9d1ee3dcb3cde1cade to your computer and use it in GitHub Desktop.
Save juanpicado/2f9d1ee3dcb3cde1cade to your computer and use it in GitHub Desktop.
Running Test in Chromedriver + wd.js + Android Device

Running Test in Chromedriver + wd.js + Android Device

Setup the Environment

$you> adb start-server
$you> adb devices
List of devices attached
12n45n54b       device

Note: Ensure your device has been detected

$you> chromedriver --url-base=wd/hub --verbose
Starting ChromeDriver (v2.9.248315) on port 9515

Running the Test

I assume you have Node.js already installed, we need to configure your JS environment.

npm install wd
  • Execute the test
node wd.foo.test.js
  • Look closely your phone ;) And enjoy the dance !!
var wd = require('wd');
var browser = wd.remote('localhost', 9515);
browser.init({
browserName:"chrome",
chromeOptions:{
"androidPackage":"com.android.chrome"
}}, function() {
browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() {
browser.title(function(err, title) {
title.should.include('WD');
browser.elementById('i am a link', function(err, el) {
browser.clickElement(el, function() {
/* jshint evil: true */
browser.eval("window.location.href", function(err, href) {
href.should.include('guinea-pig2');
browser.quit();
});
});
});
});
});
});
@zhangcheng123
Copy link

follow your step , I find the logic between the chrome-driver and andriod webview, thx.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment