Last active
April 19, 2016 17:28
-
-
Save remarkablemark/e75af73311a2cfb12bdebd9b2f9beb81 to your computer and use it in GitHub Desktop.
Search Wikipedia with WebDriverJS.
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 characters
| var webdriver = require('selenium-webdriver'); | |
| var By = webdriver.By; | |
| var driver = new webdriver.Builder().forBrowser('safari').build(); | |
| driver | |
| .get('https://www.wikipedia.org') | |
| .then(function() { | |
| return driver.sleep(1000); | |
| }) | |
| .then(function() { | |
| return driver.findElement(By.name('search')).sendKeys('webdriver'); | |
| }) | |
| .then(function() { | |
| return driver.sleep(1000); | |
| }) | |
| .then(function() { | |
| return driver.findElement(By.name('go')); | |
| }) | |
| .then(function(webElement) { | |
| webElement.click(); | |
| return driver.sleep(2000); | |
| }) | |
| .then(function() { | |
| return driver.getTitle(); | |
| }) | |
| .then(function(title) { | |
| console.log(title); | |
| driver.quit(); | |
| }); | |
| console.log('end'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment