Skip to content

Instantly share code, notes, and snippets.

@remarkablemark
Last active April 19, 2016 17:28
Show Gist options
  • Select an option

  • Save remarkablemark/e75af73311a2cfb12bdebd9b2f9beb81 to your computer and use it in GitHub Desktop.

Select an option

Save remarkablemark/e75af73311a2cfb12bdebd9b2f9beb81 to your computer and use it in GitHub Desktop.
Search Wikipedia with WebDriverJS.
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