Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add extra functions to wd
"use strict";
var wd = require("wd");
require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
var should = chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;
describe("Add function test", function () {
this.timeout(300000);
var driver;
before(function () {
var serverConfig = {
host: 'localhost',
port: 4444
};
wd.addPromiseChainMethod(
'printDebugLog',
function (msg) {
console.log(msg);
return this;
}
);
wd.addAsyncMethod(
'asyncprintDebugLog',
function (id/*, cb */) {
var cb = wd.findCallback(arguments);
var _this = this;
this.waitForElementById(id)
.getValue(function (err, value) {
console.log('ID ' + id + '\'s ' + value);
cb();
});
}
);
driver = wd.promiseChainRemote(serverConfig);
var desired = {
browserName: 'firefox',
};
return driver.init(desired);
});
after(function (done) {
driver.quit().nodeify(done);
});
it ('Add function test', function (done) {
return driver.get('http://www.google.co.jp')
.waitForElementById('lst-ib')
.type('linux')
.waitForElementByName('btnK')
.click()
.printDebugLog('hello, world')
.saveScreenshot('001.png')
.sleep(1500)
.saveScreenshot('002.png')
.asyncprintDebugLog('lst-ib', function () {
console.log('ok');
})
.nodeify(done);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment