webdriverio
Advanced tools
Comparing version 2.1.2 to 2.2.0
# CHANGELOG | ||
## v2.2.0 (2014-09-01) | ||
* new commands: | ||
- [elementIdElement](http://webdriver.io/api/protocol/elementIdElement.html) | ||
- [elementIdElements](http://webdriver.io/api/protocol/elementIdElements.html) | ||
- [selectorExecute](http://webdriver.io/api/action/selectorExecute.html) | ||
- [selectorExecuteAsync](http://webdriver.io/api/action/selectorExecuteAsync.html) | ||
- [setViewportSize](http://webdriver.io/api/window/setViewportSize.html) | ||
- [getViewportSize](http://webdriver.io/api/window/getViewportSize.html) | ||
* improved waitfor commands - now with support if all selector strategries (thanks to selectorExecuteAsync and @nickyout) | ||
## v2.1.2 (2014-08-22) | ||
@@ -12,3 +22,5 @@ * Fix: log command expecting an object and not a string | ||
## v2.1.0 (2014-08-11) | ||
* added isEnabled and elementIdEnabled commands | ||
* new commands: | ||
- [isEnabled](http://webdriver.io/api/state/isEnabled.html) | ||
- [elementIdEnabled](http://webdriver.io/api/protocol/elementIdEnabled.html) | ||
* make ErrorHandler easy accessible | ||
@@ -15,0 +27,0 @@ |
@@ -34,4 +34,4 @@ /** | ||
var async = require('async'), | ||
getHTMLHelper = require('../helpers/getHTML'), | ||
ErrorHandler = require('../utils/ErrorHandler.js'); | ||
getHTMLHelper = require('../helpers/_getHTML'), | ||
ErrorHandler = require('../utils/ErrorHandler'); | ||
@@ -38,0 +38,0 @@ module.exports = function getHTML(selector, includeSelectorTag) { |
@@ -36,3 +36,3 @@ /** | ||
var async = require('async'), | ||
newWindowHelper = require('../helpers/newWindow'), | ||
newWindowHelper = require('../helpers/_newWindow'), | ||
ErrorHandler = require('../utils/ErrorHandler.js'); | ||
@@ -39,0 +39,0 @@ |
@@ -31,3 +31,3 @@ /** | ||
var async = require('async'), | ||
scrollHelper = require('../helpers/scroll'); | ||
scrollHelper = require('../helpers/_scroll'); | ||
@@ -34,0 +34,0 @@ module.exports = function scroll (selector, xoffset, yoffset) { |
@@ -8,7 +8,7 @@ /** | ||
* | ||
* @param {String} selector element to wait for (has to be a CSS selector) | ||
* @param {String} selector element to wait for | ||
* @param {Number=} ms time in ms (default: 500) | ||
* @param {Boolean=} reverse if true it waits for the opposite (default: false) | ||
* | ||
* @uses protocol/executeAsync, protocol/timeoutsAsyncScript | ||
* @uses action/selectorExecuteAsync, protocol/timeoutsAsyncScript | ||
* @type utility | ||
@@ -19,4 +19,4 @@ * | ||
var async = require('async'), | ||
isCheckedFunc = require('../helpers/isChecked.js'), | ||
ErrorHandler = require('../utils/ErrorHandler.js'); | ||
isCheckedFunc = require('../helpers/_isChecked'), | ||
ErrorHandler = require('../utils/ErrorHandler'); | ||
@@ -57,6 +57,6 @@ module.exports = function waitForChecked(selector, ms, reverse) { | ||
response.timeoutsAsyncScript = res; | ||
self.executeAsync(isCheckedFunc, selector, reverse, cb); | ||
self.selectorExecuteAsync(selector, isCheckedFunc, reverse, cb); | ||
}, | ||
function(res, cb) { | ||
response.executeAsync = res; | ||
function(result, res, cb) { | ||
response.selectorExecuteAsync = res; | ||
cb(); | ||
@@ -66,3 +66,3 @@ } | ||
callback(err, response.executeAsync ? response.executeAsync.value : false, response); | ||
callback(err, response.selectorExecuteAsync && response.selectorExecuteAsync.executeAsync ? response.selectorExecuteAsync.executeAsync.value : false, response); | ||
@@ -69,0 +69,0 @@ }); |
@@ -8,7 +8,7 @@ /** | ||
* | ||
* @param {String} selector element to wait for (has to be a CSS selector) | ||
* @param {String} selector element to wait for | ||
* @param {Number=} ms time in ms (default: 500) | ||
* @param {Boolean=} reverse if true it waits for the opposite (default: false) | ||
* | ||
* @uses protocol/executeAsync, protocol/timeoutsAsyncScript | ||
* @uses action/selectorExecuteAsync, protocol/timeoutsAsyncScript | ||
* @type utility | ||
@@ -19,4 +19,4 @@ * | ||
var async = require('async'), | ||
isEnabledFunc = require('../helpers/isEnabled.js'), | ||
ErrorHandler = require('../utils/ErrorHandler.js'); | ||
isEnabledFunc = require('../helpers/_isEnabled'), | ||
ErrorHandler = require('../utils/ErrorHandler'); | ||
@@ -57,6 +57,6 @@ module.exports = function waitForEnabled(selector, ms, reverse) { | ||
response.timeoutsAsyncScript = res; | ||
self.executeAsync(isEnabledFunc, selector, reverse, cb); | ||
self.selectorExecuteAsync(selector, isEnabledFunc, reverse, cb); | ||
}, | ||
function(res, cb) { | ||
response.executeAsync = res; | ||
function(result, res, cb) { | ||
response.selectorExecuteAsync = res; | ||
cb(); | ||
@@ -66,3 +66,3 @@ } | ||
callback(err, response.executeAsync ? response.executeAsync.value : false, response); | ||
callback(err, response.selectorExecuteAsync && response.selectorExecuteAsync.executeAsync ? response.selectorExecuteAsync.executeAsync.value : false, response); | ||
@@ -69,0 +69,0 @@ }); |
@@ -8,7 +8,7 @@ /** | ||
* | ||
* @param {String} selector element to wait for (has to be a CSS selector) | ||
* @param {String} selector element to wait for | ||
* @param {Number=} ms time in ms (default: 500) | ||
* @param {Boolean=} reverse if true it waits for the opposite (default: false) | ||
* | ||
* @uses protocol/executeAsync, protocol/timeoutsAsyncScript | ||
* @uses action/selectorExecuteAsync, protocol/timeoutsAsyncScript | ||
* @type utility | ||
@@ -19,3 +19,2 @@ * | ||
var async = require('async'), | ||
isExistentFunc = require('../helpers/isExistent.js'), | ||
ErrorHandler = require('../utils/ErrorHandler.js'); | ||
@@ -49,22 +48,43 @@ | ||
var self = this, | ||
response = {}; | ||
async.waterfall([ | ||
function(cb) { | ||
self.timeoutsAsyncScript(ms, cb); | ||
response = { | ||
elements: [] | ||
}, | ||
function(res, cb) { | ||
response.timeoutsAsyncScript = res; | ||
self.executeAsync(isExistentFunc, selector, reverse, cb); | ||
}, | ||
function(res, cb) { | ||
response.executeAsync = res; | ||
cb(); | ||
} | ||
], function(err) { | ||
start = new Date().getTime(); | ||
callback(err, response.executeAsync ? response.executeAsync.value : false, response); | ||
function repeater() { | ||
}); | ||
async.waterfall([ | ||
function(cb) { | ||
self.pause(250).elements(selector, cb); | ||
}, | ||
function(res, cb) { | ||
response.elements.push(res); | ||
var isExistent = res.value.length > 0; | ||
if(res && res.value && ((!reverse && isExistent) || (reverse && !isExistent))) { | ||
return cb(null, true); | ||
} | ||
var now = new Date().getTime(); | ||
if(now - start > ms) { | ||
return cb(null, false); | ||
} | ||
return cb(); | ||
} | ||
], function(err, res) { | ||
if(!err && typeof res !== 'boolean') { | ||
return repeater(); | ||
} | ||
callback(err, res, response); | ||
}); | ||
} | ||
repeater(); | ||
}; |
@@ -8,7 +8,7 @@ /** | ||
* | ||
* @param {String} selector element to wait for (has to be a CSS selector) | ||
* @param {String} selector element to wait for | ||
* @param {Number=} ms time in ms (default: 500) | ||
* @param {Boolean=} reverse if true it waits for the opposite (default: false) | ||
* | ||
* @uses protocol/executeAsync, protocol/timeoutsAsyncScript | ||
* @uses protocol/selectorExecuteAsync, protocol/timeoutsAsyncScript | ||
* @type utility | ||
@@ -19,4 +19,4 @@ * | ||
var async = require('async'), | ||
isSelectedFunc = require('../helpers/isSelected.js'), | ||
ErrorHandler = require('../utils/ErrorHandler.js'); | ||
isSelectedFunc = require('../helpers/_isSelected'), | ||
ErrorHandler = require('../utils/ErrorHandler'); | ||
@@ -57,6 +57,6 @@ module.exports = function waitForSelected(selector, ms, reverse) { | ||
response.timeoutsAsyncScript = res; | ||
self.executeAsync(isSelectedFunc, selector, reverse, cb); | ||
self.selectorExecuteAsync(selector, isSelectedFunc, reverse, cb); | ||
}, | ||
function(res, cb) { | ||
response.executeAsync = res; | ||
function(result, res, cb) { | ||
response.selectorExecuteAsync = res; | ||
cb(); | ||
@@ -66,3 +66,3 @@ } | ||
callback(err, response.executeAsync ? response.executeAsync.value : false, response); | ||
callback(err, response.selectorExecuteAsync && response.selectorExecuteAsync.executeAsync ? response.selectorExecuteAsync.executeAsync.value : false, response); | ||
@@ -69,0 +69,0 @@ }); |
@@ -8,7 +8,7 @@ /** | ||
* | ||
* @param {String} selector element to wait for (has to be a CSS selector) | ||
* @param {String} selector element to wait for | ||
* @param {Number=} ms time in ms (default: 500) | ||
* @param {Boolean=} reverse if true it waits for the opposite (default: false) | ||
* | ||
* @uses protocol/executeAsync, protocol/timeoutsAsyncScript | ||
* @uses protocol/selectorExecuteAsync, protocol/timeoutsAsyncScript | ||
* @type utility | ||
@@ -19,4 +19,4 @@ * | ||
var async = require('async'), | ||
hasTextFunc = require('../helpers/hasText.js'), | ||
ErrorHandler = require('../utils/ErrorHandler.js'); | ||
hasTextFunc = require('../helpers/_hasText'), | ||
ErrorHandler = require('../utils/ErrorHandler'); | ||
@@ -57,6 +57,6 @@ module.exports = function waitForText(selector, ms, reverse) { | ||
response.timeoutsAsyncScript = res; | ||
self.executeAsync(hasTextFunc, selector, reverse, cb); | ||
self.selectorExecuteAsync(selector, hasTextFunc, reverse, cb); | ||
}, | ||
function(res, cb) { | ||
response.executeAsync = res; | ||
function(result, res, cb) { | ||
response.selectorExecuteAsync = res; | ||
cb(); | ||
@@ -66,3 +66,3 @@ } | ||
callback(err, response.executeAsync ? response.executeAsync.value : false, response); | ||
callback(err, response.selectorExecuteAsync && response.selectorExecuteAsync.executeAsync ? response.selectorExecuteAsync.executeAsync.value : false, response); | ||
@@ -69,0 +69,0 @@ }); |
@@ -8,7 +8,7 @@ /** | ||
* | ||
* @param {String} selector element to wait for (has to be a CSS selector) | ||
* @param {String} selector element to wait | ||
* @param {Number=} ms time in ms (default: 500) | ||
* @param {Boolean=} reverse if true it waits for the opposite (default: false) | ||
* | ||
* @uses protocol/executeAsync, protocol/timeoutsAsyncScript | ||
* @uses protocol/selectorExecuteAsync, protocol/timeoutsAsyncScript | ||
* @type utility | ||
@@ -19,4 +19,4 @@ * | ||
var async = require('async'), | ||
hasValueFunc = require('../helpers/hasValue.js'), | ||
ErrorHandler = require('../utils/ErrorHandler.js'); | ||
hasValueFunc = require('../helpers/_hasValue'), | ||
ErrorHandler = require('../utils/ErrorHandler'); | ||
@@ -57,6 +57,6 @@ module.exports = function waitForValue(selector, ms, reverse) { | ||
response.timeoutsAsyncScript = res; | ||
self.executeAsync(hasValueFunc, selector, reverse, cb); | ||
self.selectorExecuteAsync(selector, hasValueFunc, reverse, cb); | ||
}, | ||
function(res, cb) { | ||
response.executeAsync = res; | ||
function(result, res, cb) { | ||
response.selectorExecuteAsync = res; | ||
cb(); | ||
@@ -66,3 +66,3 @@ } | ||
callback(err, response.executeAsync ? response.executeAsync.value : false, response); | ||
callback(err, response.selectorExecuteAsync && response.selectorExecuteAsync.executeAsync ? response.selectorExecuteAsync.executeAsync.value : false, response); | ||
@@ -69,0 +69,0 @@ }); |
@@ -8,7 +8,7 @@ /** | ||
* | ||
* @param {String} selector element to wait for (has to be a CSS selector) | ||
* @param {String} selector element to wait for | ||
* @param {Number=} ms time in ms (default: 500) | ||
* @param {Boolean=} reverse if true it waits for the opposite (default: false) | ||
* | ||
* @uses protocol/executeAsync, protocol/timeoutsAsyncScript | ||
* @uses protocol/selectorExecuteAsync, protocol/timeoutsAsyncScript | ||
* @type utility | ||
@@ -19,3 +19,3 @@ * | ||
var async = require('async'), | ||
isVisibleFunc = require('../helpers/isVisible.js'), | ||
isVisibleFunc = require('../helpers/_isVisible.js'), | ||
ErrorHandler = require('../utils/ErrorHandler.js'); | ||
@@ -57,6 +57,6 @@ | ||
response.timeoutsAsyncScript = res; | ||
self.executeAsync(isVisibleFunc, selector, reverse, cb); | ||
self.selectorExecuteAsync(selector, isVisibleFunc, reverse, cb); | ||
}, | ||
function(res, cb) { | ||
response.executeAsync = res; | ||
function(result, res, cb) { | ||
response.selectorExecuteAsync = res; | ||
cb(); | ||
@@ -66,3 +66,3 @@ } | ||
callback(err, response.executeAsync ? response.executeAsync.value : false, response); | ||
callback(err, response.selectorExecuteAsync && response.selectorExecuteAsync.executeAsync ? response.selectorExecuteAsync.executeAsync.value : false, response); | ||
@@ -69,0 +69,0 @@ }); |
@@ -82,2 +82,8 @@ var util = require('util'), | ||
/** | ||
* chainit stringifies command arguments and calls this function to give us information about | ||
* which command was called | ||
* | ||
* @param {Object} cmd contains object with command name and args | ||
*/ | ||
ErrorHandler.prototype.addToCallStack = function(cmd) { | ||
@@ -89,2 +95,15 @@ if(!this.hasCallStack) { | ||
/** | ||
* since JSON.stringify() omits to serialize function attributes we need replace the first appearance | ||
* of "none" in all execute functions with "[Function]" | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify | ||
* | ||
* > If undefined, a function, or a symbol is encountered during conversion it is either omitted | ||
* (when it is found in an object) or censored to null (when it is found in an array). | ||
*/ | ||
if(cmd.name.match(/(e|E)xecute/)) { | ||
cmd.args = cmd.args.replace(/null/,'[Function]'); | ||
} | ||
this.message += pad('-> ', 9) + cmd.name + cmd.args + '\n'; | ||
@@ -91,0 +110,0 @@ }; |
{ | ||
"name": "webdriverio", | ||
"description": "A nodejs bindings implementation for selenium 2.0/webdriver", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"homepage": "https://github.com/webdriverio/webdriverio", | ||
@@ -34,3 +34,3 @@ "author": "Camilo Tapia <camilo.tapia@gmail.com>", | ||
"test-functional": "_ENV=functional _BROWSER=phantomjs node ./test/runner.js", | ||
"coverage": "./node_modules/.bin/istanbul cover -x \"**/helpers/is*.js\" -x \"**/helpers/click.js\" -x \"**/helpers/has*.js\" -x \"**/helpers/getHTML.js\" -x \"**/helpers/scroll.js\" -x \"**/helpers/newWindow.js\" ./test/runner.js", | ||
"coverage": "./node_modules/.bin/istanbul cover -x \"**/helpers/_*.js\" ./test/runner.js", | ||
"prepublish": "npm prune" | ||
@@ -48,3 +48,4 @@ }, | ||
"rgb2hex": "^0.1.0", | ||
"url": "^0.10.1" | ||
"url": "^0.10.1", | ||
"wgxpath": "^0.23.0" | ||
}, | ||
@@ -51,0 +52,0 @@ "devDependencies": { |
@@ -44,3 +44,3 @@ /* global beforeEach */ | ||
it.skip('should close the current window to switch back to another tab', function(done) { | ||
it('should close the current window to switch back to another tab', function(done) { | ||
@@ -47,0 +47,0 @@ /** |
@@ -5,2 +5,11 @@ describe('drag&drop command test', function() { | ||
it('should drag and drop an element', function(done) { | ||
/** | ||
* skip for ie | ||
* not working anymore | ||
*/ | ||
if(process.env._BROWSER === 'internet_explorer') { | ||
done(); | ||
} | ||
this.client | ||
@@ -7,0 +16,0 @@ .getValue('.searchinput', function(err,res) { |
@@ -22,2 +22,3 @@ /** | ||
it('should return two tab ids after openening a new window', function(done) { | ||
var tabsIds; | ||
@@ -27,2 +28,3 @@ this.client | ||
.getTabIds(function(err, tabs) { | ||
tabsIds = tabs; | ||
assert.ifError(err); | ||
@@ -32,2 +34,5 @@ tabs.should.be.an.instanceOf(Array); | ||
}) | ||
.call(function() { | ||
this.close(tabsIds[0]); | ||
}) | ||
.call(done); | ||
@@ -34,0 +39,0 @@ |
@@ -27,2 +27,3 @@ describe('switchTab', function() { | ||
}) | ||
.close() | ||
.call(done); | ||
@@ -29,0 +30,0 @@ |
@@ -43,3 +43,3 @@ /*jshint expr: true*/ | ||
var currentTime = Date.now(); | ||
this.client.waitForChecked('.radio_waitForSelected', duration, checkTime(currentTime, done)); | ||
this.client.waitForChecked('//html/body/section/input[6]', duration, checkTime(currentTime, done)); | ||
}); | ||
@@ -60,3 +60,3 @@ | ||
var currentTime = Date.now(); | ||
this.client.waitForEnabled('.waitForValueEnabled', duration, checkTime(currentTime, done)); | ||
this.client.waitForEnabled('//html/body/section/input[8]', duration, checkTime(currentTime, done)); | ||
}); | ||
@@ -77,3 +77,3 @@ | ||
var currentTime = Date.now(); | ||
this.client.waitForExist('.lateElem', duration, checkTime(currentTime, done)); | ||
this.client.waitForExist('//div[text()="Sorry, I\'m late!"]', duration, checkTime(currentTime, done)); | ||
}); | ||
@@ -94,3 +94,3 @@ | ||
var currentTime = Date.now(); | ||
this.client.waitForSelected('.option3', duration, checkTime(currentTime, done)); | ||
this.client.waitForSelected('//*[@id="selectbox"]/option[3]', duration, checkTime(currentTime, done)); | ||
}); | ||
@@ -111,3 +111,3 @@ | ||
var currentTime = Date.now(); | ||
this.client.waitForText('.sometextlater', duration, checkTime(currentTime, done)); | ||
this.client.waitForText('//*[contains(@class, "sometextlater")]', duration, checkTime(currentTime, done)); | ||
}); | ||
@@ -133,3 +133,3 @@ | ||
var currentTime = Date.now(); | ||
this.client.waitForEnabled('.waitForValueEnabledReverse', duration, true, checkTime(currentTime, done)); | ||
this.client.waitForEnabled('//*[contains(@class, "waitForValueEnabledReverse")]', duration, true, checkTime(currentTime, done)); | ||
}); | ||
@@ -145,3 +145,3 @@ | ||
var currentTime = Date.now(); | ||
this.client.waitForVisible('.notInViewport', duration, checkTime(currentTime, done)); | ||
this.client.waitForVisible('//*[contains(@class, "notInViewport")]', duration, checkTime(currentTime, done)); | ||
}); | ||
@@ -148,0 +148,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1098343
303
10770
11
23
+ Addedwgxpath@^0.23.0
+ Addedwgxpath@0.23.0(transitive)