Last active
June 2, 2016 18:43
-
-
Save bertolo1988/28fbecbd81293b76d5b4f85105c58f7e to your computer and use it in GitHub Desktop.
Grab top questions from stackoverflow.com fidElements example javascript webdriverjs
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 timeout = 80000; | |
var webdriver = require('selenium-webdriver'), | |
By = webdriver.By, | |
until = webdriver.until; | |
var driver = new webdriver.Builder() | |
.forBrowser('chrome') | |
.build(); | |
driver.get('http://stackoverflow.com/'); | |
driver.wait(function() { | |
return driver.findElement(By.id('h-top-questions')).isDisplayed(); | |
}, timeout); | |
var mainBar = driver.findElement(By.id('mainbar')); | |
var questionSelector = 'div.summary > h3 > a'; | |
mainBar.findElements(By.css(questionSelector)).then(function(elements) { | |
elements.forEach(function(val, idx) { | |
elements[idx].getText().then(function(text) { | |
console.log(text); | |
}); | |
}); | |
}); | |
driver.quit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment