Created
February 16, 2017 13:26
-
-
Save haisi/514eeec884b6c45fcd8b25a79a7af2db to your computer and use it in GitHub Desktop.
Revisions
-
haisi created this gist
Feb 16, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ 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();