Skip to content

Instantly share code, notes, and snippets.

@dmitrym0
Created January 21, 2014 18:18
Show Gist options
  • Save dmitrym0/8545228 to your computer and use it in GitHub Desktop.
Save dmitrym0/8545228 to your computer and use it in GitHub Desktop.
A selenium webdriverjs test that hangs getting element text
var assert = require('assert'),
test = require('selenium-webdriver/testing'),
webdriver = require('selenium-webdriver'),
SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
var driver = new webdriver.Builder().
usingServer("http://localhost:9515").
withCapabilities(webdriver.Capabilities.chrome()).
build();
test.describe('getting main page', function() {
test.it('should be able to get the header text', function(){
driver.get('http://localhost:8080/?epub=epub_content%2Flinear-algebra')
.then(function() {
driver.sleep(1000);
driver.switchTo().frame('epubContentIframe');
})
.then(function() {
var allElements = driver.findElements({tagName: 'h1'});
allElements.then(function(val){
console.log("Got all elements=" + val.length);
val[0].getText().then(function(txt) {
console.log("element text=" + txt);
});
});
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment