Created
September 2, 2013 20:15
-
-
Save christian-bromann/6416885 to your computer and use it in GitHub Desktop.
run WebdriverJS with Mocha
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 webdriverjs = require('webdriverjs'), | |
assert = require('assert'); | |
describe('my webdriverjs tests', function(){ | |
this.timeout(99999999); | |
var client = {}; | |
before(function(){ | |
client = webdriverjs.remote({ desiredCapabilities: {browserName: 'phantomjs'} }); | |
client.init(); | |
}); | |
it('Github test',function(done) { | |
client | |
.url('https://github.com/') | |
.getElementSize('.header-logo-wordmark', function(err, result) { | |
assert(err === null); | |
assert(result.height === 32); | |
assert(result.width === 89); | |
}) | |
.getTitle(function(err, title) { | |
assert(err === null); | |
assert(title === 'GitHub · Build software better, together.'); | |
}) | |
.getElementCssProperty('css selector','a[href="/plans"]', 'color', function(err, result){ | |
assert(err === null); | |
assert(result === 'rgba(65,131,196,1)'); | |
}) | |
.call(done); | |
}); | |
after(function(done) { | |
client.end(done); | |
}); | |
}); |
Worked for me! Woo-Hoo So, who will win WebDriver.io or WebDriverJS?! The race is on! lol
I get an error "describe is not defined" when i try to run the script. Am i missing something?
@sri85 Are you running it with mocha (and not node directly)?
mocha webdriverjs.with.mocha.js
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think mocha's
done
callback has to be passed toclient.init()
like so:Without passing the
done()
callback toinit()
the test fails upon the second re-execution due to a code change when usingmocha -w
(i.e watch mode):