Skip to content

Instantly share code, notes, and snippets.

@haisi
Created February 16, 2017 13:26
Show Gist options
  • Save haisi/514eeec884b6c45fcd8b25a79a7af2db to your computer and use it in GitHub Desktop.
Save haisi/514eeec884b6c45fcd8b25a79a7af2db to your computer and use it in GitHub Desktop.
var webdriver = require('selenium-webdriver');
var keyword = "Magic";
var driver = new webdriver.Builder().
usingServer('http://localhost:4444/wd/hub/').
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('http://www.google.com');
driver.findElement(webdriver.By.name('q')).sendKeys(keyword);
driver.findElement(webdriver.By.name('btnG')).click();
driver.wait(function() {
return driver.getTitle().then(function(title) {
return driver.getPageSource().then(function(html) {
console.log(html);
return true;
});
});
}, 1000);
driver.quit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment