Created
February 16, 2017 13:26
-
-
Save haisi/514eeec884b6c45fcd8b25a79a7af2db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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