Skip to content

Commit

Permalink
Adding chromedriver example
Browse files Browse the repository at this point in the history
  • Loading branch information
sebv committed Nov 30, 2013
1 parent a742e60 commit 988df6b
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions examples/promise/chromedriver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
chai.should();

var wd;
try {
wd = require('wd');
} catch( err ) {
wd = require('../../lib/main');
}

// enables chai assertion chaining
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

var browser = wd.promiseChainRemote('http://localhost:9515/');

// optional extra logging
//browser._debugPromise();
browser.on('status', function(info) {
console.log(info.cyan);
});
browser.on('command', function(meth, path, data) {
console.log(' > ' + meth.yellow, path.grey, data || '');
});

/* jshint evil: true */
browser
.status()
.init({browserName:'chrome'})
.get("http://admc.io/wd/test-pages/guinea-pig.html")
.title()
.should.become('WD Tests')
.elementById('i am a link')
.click()
.eval("window.location.href")
.should.eventually.include('guinea-pig2')
.back()
.elementByCss('#comments').type('Bonjour!')
.getValue().should.become('Bonjour!')
.fin(function() { return browser.quit(); })
.catch(function(err) {
console.log(err);
console.log(err.data);
})
.done();

0 comments on commit 988df6b

Please sign in to comment.