Skip to content

Instantly share code, notes, and snippets.

@masami256
Created May 22, 2015 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masami256/3b28a3b161b6e98aabb4 to your computer and use it in GitHub Desktop.
Save masami256/3b28a3b161b6e98aabb4 to your computer and use it in GitHub Desktop.
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