Created
May 22, 2015 16:09
-
-
Save masami256/3b28a3b161b6e98aabb4 to your computer and use it in GitHub Desktop.
Add extra functions to wd
This file contains 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
"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