UNPKG

webdriverjs

Version:

A nodejs bindings implementation for selenium 2.0/webdriver

49 lines (43 loc) 1.58 kB
describe('script execution', function() { before(h.setup); it('should be able to execute some js', function(done) { this.client .execute('return document.title', [], function(err, res) { assert.equal(null, err); assert.equal(conf.testPage.title, res.value); done(err); }); }); it('should be forgiving on giving an `args` parameter', function(done) { this.client .execute('return document.title', function(err, res) { assert.equal(null, err); assert.equal(conf.testPage.title, res.value); done(err); }); }); it('should be able to execute a pure function', function(done) { this.client .execute(function() { return document.title; }, function(err, res) { assert.equal(null, err); assert.equal(conf.testPage.title, res.value); done(err); }); }); it('should provide an executeAsync method', function(done) { this.client .timeouts('script', 5000) .executeAsync(function() { var cb = arguments[arguments.length - 1]; setTimeout(function() { cb(document.title + '-async'); }, 500); }, function(err, res) { assert.equal(null, err); assert.equal(conf.testPage.title + '-async', res.value); done(err); }); }); });