Comparing version 0.2.4 to 0.2.5
@@ -1084,3 +1084,3 @@ <table class="wikitable"> | ||
Waits for JavaScript condition to be true (async script polling within browser):<br> | ||
waitForConditionInBrowser(conditionExpr, timeout, pollFreq, cb) -> cb(err, boolean) <br> | ||
waitForConditionInBrowser(conditionExpr, timeout, pollFreq, cb) -> cb(err, boolean)<br> | ||
conditionExpr: condition expression, should return a boolean<br> | ||
@@ -1087,0 +1087,0 @@ timeout and pollFreq are optional, default: 1000/100.<br> |
@@ -1291,3 +1291,3 @@ <table class="wikitable"> | ||
Waits for JavaScript condition to be true (async script polling within browser):<br> | ||
waitForConditionInBrowser(conditionExpr, timeout, pollFreq, cb) -> cb(err, boolean) <br> | ||
waitForConditionInBrowser(conditionExpr, timeout, pollFreq, cb) -> cb(err, boolean)<br> | ||
conditionExpr: condition expression, should return a boolean<br> | ||
@@ -1294,0 +1294,0 @@ timeout and pollFreq are optional, default: 1000/100.<br> |
@@ -39,6 +39,10 @@ # Release Notes | ||
### 0.2.4 (in progress) | ||
### 0.2.4 | ||
- bugfix: android safeExecute. | ||
- bugfix: passing argument to execute. | ||
- bugfix: setOrientation. | ||
- migrating from string.js to underscore.string (todo). | ||
- migrating from string.js to underscore.string. | ||
### 0.2.5 | ||
- Webdriver and Element refactoring | ||
- Easier wd customization via `wd.setBaseClasses(Webdriver, Element)` |
@@ -8,3 +8,3 @@ //Element object | ||
var element = function(value, browser) { | ||
var Element = function(value, browser) { | ||
this.value = value; | ||
@@ -14,19 +14,19 @@ this.browser = browser; | ||
if(!value){ | ||
throw new Error("no value passed to element constructor"); | ||
throw new Error("no value passed to Element constructor"); | ||
} | ||
if(!browser){ | ||
throw new Error("no browser passed to element constructor"); | ||
throw new Error("no browser passed to Element constructor"); | ||
} | ||
}; | ||
element.prototype.emit = function() { | ||
Element.prototype.emit = function() { | ||
this.browser.emit.apply(this.browser, __slice.call(arguments, 0)); | ||
}; | ||
element.prototype.toString = function () { | ||
Element.prototype.toString = function () { | ||
return String(this.value); | ||
}; | ||
element.prototype.toJSON = function () { | ||
Element.prototype.toJSON = function () { | ||
return { ELEMENT: this.value }; | ||
@@ -40,3 +40,3 @@ }; | ||
*/ | ||
element.prototype.type = function (keys, cb) { | ||
Element.prototype.type = function (keys, cb) { | ||
return this.browser.type(this, keys, cb); | ||
@@ -50,3 +50,3 @@ }; | ||
*/ | ||
element.prototype.keys = function (keys, cb) { | ||
Element.prototype.keys = function (keys, cb) { | ||
return this.browser.keys(keys, cb); | ||
@@ -70,3 +70,3 @@ }; | ||
*/ | ||
element.prototype.sendKeys = function (keys, cb) { | ||
Element.prototype.sendKeys = function (keys, cb) { | ||
var _this = this; | ||
@@ -101,3 +101,3 @@ if (!(keys instanceof Array)) {keys = [keys];} | ||
*/ | ||
element.prototype.click = function (cb) { | ||
Element.prototype.click = function (cb) { | ||
return this.browser.clickElement(this, cb); | ||
@@ -111,3 +111,3 @@ }; | ||
*/ | ||
element.prototype.tap = function (cb) { | ||
Element.prototype.tap = function (cb) { | ||
return this.browser.tapElement(this, cb); | ||
@@ -121,3 +121,3 @@ }; | ||
*/ | ||
element.prototype.doubleclick = function(cb) { | ||
Element.prototype.doubleclick = function(cb) { | ||
return this.browser.moveTo(this, function(err) { | ||
@@ -129,3 +129,3 @@ if(err) { return cb(err); } | ||
element.prototype.doubleClick = element.prototype.doubleclick; | ||
Element.prototype.doubleClick = Element.prototype.doubleclick; | ||
@@ -138,3 +138,3 @@ /** | ||
*/ | ||
element.prototype.moveTo = function() { | ||
Element.prototype.moveTo = function() { | ||
var fargs = utils.varargs(arguments); | ||
@@ -152,3 +152,3 @@ var cb = fargs.callback, | ||
*/ | ||
element.prototype.flick = function (xoffset, yoffset, speed, cb) { | ||
Element.prototype.flick = function (xoffset, yoffset, speed, cb) { | ||
return this.browser.flick(this.value, xoffset, yoffset, speed, cb); | ||
@@ -164,3 +164,3 @@ }; | ||
*/ | ||
element.prototype.text = function (cb) { | ||
Element.prototype.text = function (cb) { | ||
return this.browser.text(this, cb); | ||
@@ -175,3 +175,3 @@ }; | ||
*/ | ||
element.prototype.textPresent = function(searchText, cb) { | ||
Element.prototype.textPresent = function(searchText, cb) { | ||
return this.browser.textPresent(searchText, this, cb); | ||
@@ -186,3 +186,3 @@ }; | ||
*/ | ||
element.prototype.getAttribute = function(name, cb) { | ||
Element.prototype.getAttribute = function(name, cb) { | ||
return this.browser.getAttribute(this, name, cb); | ||
@@ -196,3 +196,3 @@ }; | ||
*/ | ||
element.prototype.getTagName = function(cb) { | ||
Element.prototype.getTagName = function(cb) { | ||
return this.browser.getTagName(this, cb); | ||
@@ -206,7 +206,7 @@ }; | ||
*/ | ||
element.prototype.isDisplayed = function(cb) { | ||
Element.prototype.isDisplayed = function(cb) { | ||
return this.browser.isDisplayed(this, cb); | ||
}; | ||
element.prototype.displayed = element.prototype.isDisplayed; | ||
Element.prototype.displayed = Element.prototype.isDisplayed; | ||
@@ -218,7 +218,7 @@ /** | ||
*/ | ||
element.prototype.isSelected = function(cb) { | ||
Element.prototype.isSelected = function(cb) { | ||
return this.browser.isSelected(this, cb); | ||
}; | ||
element.prototype.selected = element.prototype.isSelected; | ||
Element.prototype.selected = Element.prototype.isSelected; | ||
@@ -230,7 +230,7 @@ /** | ||
*/ | ||
element.prototype.isEnabled = function(cb) { | ||
Element.prototype.isEnabled = function(cb) { | ||
return this.browser.isEnabled(this, cb); | ||
}; | ||
element.prototype.enabled = element.prototype.isEnabled; | ||
Element.prototype.enabled = Element.prototype.isEnabled; | ||
@@ -240,3 +240,3 @@ /** | ||
*/ | ||
element.prototype.isVisible = function(cb) { | ||
Element.prototype.isVisible = function(cb) { | ||
return this.browser.isVisible(this, cb); | ||
@@ -250,3 +250,3 @@ }; | ||
*/ | ||
element.prototype.getLocation = function (cb) { | ||
Element.prototype.getLocation = function (cb) { | ||
return this.browser.getLocation(this, cb); | ||
@@ -260,3 +260,3 @@ }; | ||
*/ | ||
element.prototype.getLocationInView = function (cb) { | ||
Element.prototype.getLocationInView = function (cb) { | ||
return this.browser.getLocationInView(this, cb); | ||
@@ -270,3 +270,3 @@ }; | ||
*/ | ||
element.prototype.getSize = function (cb) { | ||
Element.prototype.getSize = function (cb) { | ||
return this.browser.getSize(this, cb); | ||
@@ -281,3 +281,3 @@ }; | ||
*/ | ||
element.prototype.getValue = function(cb) { | ||
Element.prototype.getValue = function(cb) { | ||
return this.browser.getValue(this, cb); | ||
@@ -291,7 +291,7 @@ }; | ||
*/ | ||
element.prototype.getComputedCss = function(styleName, cb) { | ||
Element.prototype.getComputedCss = function(styleName, cb) { | ||
return this.browser.getComputedCss(this, styleName, cb); | ||
}; | ||
element.prototype.getComputedCSS = element.prototype.getComputedCss; | ||
Element.prototype.getComputedCSS = Element.prototype.getComputedCss; | ||
@@ -303,3 +303,3 @@ /** | ||
*/ | ||
element.prototype.clear = function(cb) { | ||
Element.prototype.clear = function(cb) { | ||
return this.browser.clear(this, cb); | ||
@@ -313,3 +313,3 @@ }; | ||
*/ | ||
element.prototype.submit = function(cb) { | ||
Element.prototype.submit = function(cb) { | ||
return this.browser.submit(this, cb); | ||
@@ -323,3 +323,3 @@ }; | ||
*/ | ||
element.prototype.getComputedCss = function(styleName, cb) { | ||
Element.prototype.getComputedCss = function(styleName, cb) { | ||
return this.browser.getComputedCss(this, styleName, cb); | ||
@@ -343,4 +343,4 @@ }; | ||
*/ | ||
element.prototype['element' + utils.elFuncSuffix(type)] = function(value, cb) { | ||
element.prototype.element.apply(this, [utils.elFuncFullType(type), value, cb]); | ||
Element.prototype['element' + utils.elFuncSuffix(type)] = function(value, cb) { | ||
this.element(utils.elFuncFullType(type), value, cb); | ||
}; | ||
@@ -362,4 +362,4 @@ | ||
*/ | ||
element.prototype['elements' + utils.elFuncSuffix(type)] = function(value, cb) { | ||
element.prototype.elements.apply(this, [utils.elFuncFullType(type), value, cb]); | ||
Element.prototype['elements' + utils.elFuncSuffix(type)] = function(value, cb) { | ||
this.elements(utils.elFuncFullType(type), value, cb); | ||
}; | ||
@@ -374,3 +374,3 @@ }); | ||
*/ | ||
element.prototype.element = function(using, value, cb) { | ||
Element.prototype.element = function(using, value, cb) { | ||
var _this = this; | ||
@@ -391,3 +391,3 @@ this.browser._jsonWireCall({ | ||
*/ | ||
element.prototype.elements = function(using, value, cb) { | ||
Element.prototype.elements = function(using, value, cb) { | ||
var _this = this; | ||
@@ -408,3 +408,3 @@ this.browser._jsonWireCall({ | ||
*/ | ||
element.prototype.equals = function(other, cb) { | ||
Element.prototype.equals = function(other, cb) { | ||
return this.browser.equalsElement(this, other, cb); | ||
@@ -416,3 +416,3 @@ }; | ||
*/ | ||
element.prototype.sleep = function(ms, cb) { | ||
Element.prototype.sleep = function(ms, cb) { | ||
cb = cb || function() {}; | ||
@@ -425,6 +425,6 @@ setTimeout(cb , ms); | ||
*/ | ||
element.prototype.noop = function(cb) { | ||
Element.prototype.noop = function(cb) { | ||
if(cb) { cb(); } | ||
}; | ||
exports.element = element; | ||
module.exports = Element; |
@@ -5,2 +5,3 @@ var __slice = Array.prototype.slice; | ||
var Webdriver = require('./webdriver'); | ||
var Element = require('./element'); | ||
var utils = require('./utils'); | ||
@@ -12,6 +13,2 @@ var deprecator = utils.deprecator; | ||
var factory = exports.factory = { | ||
WebDriver: Webdriver | ||
}; | ||
function buildConfigUrl(remoteWdConfig) | ||
@@ -111,3 +108,3 @@ { | ||
return new factory.WebDriver(rwc); | ||
return new Webdriver(rwc); | ||
} | ||
@@ -119,4 +116,4 @@ | ||
function wrap() { | ||
PromiseWebdriver = require('./promise-webdriver')(factory.WebDriver, false); | ||
PromiseChainWebdriver = require('./promise-webdriver')(factory.WebDriver, true); | ||
PromiseWebdriver = require('./promise-webdriver')(Webdriver, Element, false); | ||
PromiseChainWebdriver = require('./promise-webdriver')(Webdriver, Element, true); | ||
} | ||
@@ -183,4 +180,5 @@ | ||
// Webdriver and Wrapper base classes | ||
Webdriver: factory.WebDriver, | ||
webdriver: factory.WebDriver, // for backward compatibility | ||
Webdriver: Webdriver, | ||
webdriver: Webdriver, // for backward compatibility | ||
Element: Element, | ||
PromiseChainWebdriver: PromiseChainWebdriver, | ||
@@ -254,4 +252,9 @@ PromiseWebdriver: PromiseWebdriver, | ||
// todo: That should not be needed. | ||
utils: utils | ||
utils: utils, | ||
setBaseClasses: function(_Webdriver, _Element) { | ||
Webdriver = _Webdriver; | ||
Element = _Element; | ||
wrap(); | ||
} | ||
}; |
@@ -17,3 +17,3 @@ var __slice = Array.prototype.slice, | ||
return _(Obj).functions().filter(function(fname) { | ||
return !fname.match('^toJSON$|^toString$|^_') && | ||
return !fname.match('^newElement$|^toJSON$|^toString$|^_') && | ||
!EventEmitter.prototype[fname]; | ||
@@ -23,114 +23,4 @@ }).value(); | ||
// enriches a promise with the browser + element methods. | ||
function enrich(obj, browser) { | ||
// There are cases were enrich may be called on non-promise objects. | ||
// It is easier and safer to check within the method. | ||
if(utils.isPromise(obj) && !obj.__wd_promise_enriched) { | ||
var promise = obj; | ||
module.exports = function(WebDriver, Element, chainable) { | ||
// __wd_promise_enriched is there to avoid enriching twice. | ||
promise.__wd_promise_enriched = true; | ||
// making sure all the sub-promises are also enriched. | ||
_(promise).functions().each(function(fname) { | ||
var _orig = promise[fname]; | ||
promise[fname] = function() { | ||
return enrich( | ||
_orig.apply(this, __slice.call(arguments, 0)) | ||
, browser); | ||
}; | ||
}); | ||
// we get the list of methods first cause we need it in the enrich method. | ||
var browserProto = Object.getPrototypeOf(browser); | ||
var Element = browserProto._Element; | ||
// we get the list of methods first cause we need it in the enrich method. | ||
var promisedMethods = filterPromisedMethods(browserProto); | ||
var elementPromisedMethods = | ||
Element ? filterPromisedMethods(Element.prototype) : []; | ||
var allPromisedMethods = _.union(promisedMethods, elementPromisedMethods); | ||
// adding browser + element methods to the current promise. | ||
_(allPromisedMethods).each(function(fname) { | ||
promise[fname] = function() { | ||
var args = __slice.call(arguments, 0); | ||
// This is a hint to figure out if we need to call a browser method or | ||
// an element method. | ||
// "<" --> browser method | ||
// ">" --> element method | ||
var scopeHint; | ||
if(args && args[0] && typeof args[0] === 'string' && args[0].match(/^[<>]$/)) { | ||
scopeHint = args[0]; | ||
args = _.rest(args); | ||
} | ||
return this.then(function(res) { | ||
var el; | ||
// if the result is an element it has priority | ||
if(Element && res instanceof Element) { el = res; } | ||
// testing the water for the next call scope | ||
var isBrowserMethod = | ||
_.indexOf(promisedMethods, fname) >= 0; | ||
var isElementMethod = | ||
el && _.indexOf(elementPromisedMethods, fname) >= 0; | ||
if(!isBrowserMethod && !isElementMethod) { | ||
// doesn't look good | ||
throw new Error("Invalid method " + fname); | ||
} | ||
if(isBrowserMethod && isElementMethod) { | ||
// we need to resolve the conflict. | ||
if(scopeHint === '<') { | ||
isElementMethod = false; | ||
} else if(scopeHint === '>') { | ||
isBrowserMethod = false; | ||
} else if(fname.match(/element/) || (Element && args[0] instanceof Element)) { | ||
// method with element locators are browser scoped by default. | ||
// When an element is passed, we are also obviously in the global scope. | ||
isElementMethod = false; | ||
} else { | ||
// otherwise we stay in the element scope to allow sequential calls | ||
isBrowserMethod = false; | ||
} | ||
} | ||
if(isElementMethod) { | ||
// element method case. | ||
return el[fname].apply(el, args).then(function(res) { | ||
if(_.indexOf(elementChainableMethods, fname) >= 0) { | ||
// method like click, where no result is expected, we return | ||
// the element to make it chainable | ||
return el; | ||
} else { | ||
return res; // we have no choice but loosing the scope | ||
} | ||
}); | ||
}else{ | ||
// browser case. | ||
return browser[fname].apply(browser, args); | ||
} | ||
}); | ||
}; | ||
}); | ||
// transfering _enrich | ||
promise._enrich = function(target) { | ||
return browser._enrich(target); | ||
}; | ||
// adding print error helper | ||
promise.printError = function() { | ||
return promise.catch(function(err) { | ||
console.log(err); | ||
throw err; | ||
}); | ||
}; | ||
} | ||
return obj; | ||
} | ||
module.exports = function(WebDriver, chainable) { | ||
// wraps element + browser call in an enriched promise. | ||
@@ -175,3 +65,3 @@ // This is the same as in the first promise version, but enrichment + | ||
if(chainable) { | ||
return enrich(deferred.promise, this); | ||
return this._enrich(deferred.promise); | ||
} else { | ||
@@ -183,14 +73,13 @@ return deferred.promise; | ||
var Element = WebDriver.prototype._Element; | ||
// promisify element shortcuts too | ||
var promiseElement = function() { | ||
return Element.apply(this, arguments); | ||
var PromiseElement = function() { | ||
var args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
return Element.apply(this, args); | ||
}; | ||
// Element replacement. | ||
promiseElement.prototype = Object.create(Element.prototype); | ||
PromiseElement.prototype = Object.create(Element.prototype); | ||
// WebDriver replacement. | ||
var promiseWebdriver = function() { | ||
var PromiseWebdriver = function() { | ||
var args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
@@ -200,9 +89,7 @@ return WebDriver.apply(this, args); | ||
promiseWebdriver.prototype = Object.create(WebDriver.prototype); | ||
PromiseWebdriver.prototype = Object.create(WebDriver.prototype); | ||
promiseWebdriver.prototype._Element = promiseElement; | ||
// wrapping browser methods with promises. | ||
_(filterPromisedMethods(WebDriver.prototype)).each(function(fname) { | ||
promiseWebdriver.prototype[fname] = wrap(WebDriver.prototype[fname], fname); | ||
PromiseWebdriver.prototype[fname] = wrap(WebDriver.prototype[fname], fname); | ||
}); | ||
@@ -212,5 +99,117 @@ | ||
_(filterPromisedMethods(Element.prototype)).each(function(fname) { | ||
promiseElement.prototype[fname] = wrap(Element.prototype[fname], fname); | ||
PromiseElement.prototype[fname] = wrap(Element.prototype[fname], fname); | ||
}); | ||
PromiseWebdriver.prototype.newElement = function(jsonWireElement) { | ||
return new PromiseElement(jsonWireElement, this); | ||
}; | ||
// enriches a promise with the browser + element methods. | ||
PromiseWebdriver.prototype._enrich = function(obj, currentEl) { | ||
var _this = this; | ||
// There are cases were enrich may be called on non-promise objects. | ||
// It is easier and safer to check within the method. | ||
if(utils.isPromise(obj) && !obj.__wd_promise_enriched) { | ||
var promise = obj; | ||
// __wd_promise_enriched is there to avoid enriching twice. | ||
promise.__wd_promise_enriched = true; | ||
// making sure all the sub-promises are also enriched. | ||
_(promise).functions().each(function(fname) { | ||
var _orig = promise[fname]; | ||
promise[fname] = function() { | ||
return this._enrich( | ||
_orig.apply(this, __slice.call(arguments, 0)), currentEl); | ||
}; | ||
}); | ||
// we get the list of methods dynamically. | ||
var promisedMethods = filterPromisedMethods(Object.getPrototypeOf(_this)); | ||
_this.sampleElement = _this.sampleElement || _this.newElement(1); | ||
var elementPromisedMethods = filterPromisedMethods(Object.getPrototypeOf(_this.sampleElement)); | ||
var allPromisedMethods = _.union(promisedMethods, elementPromisedMethods); | ||
// adding browser + element methods to the current promise. | ||
_(allPromisedMethods).each(function(fname) { | ||
promise[fname] = function() { | ||
var args = __slice.call(arguments, 0); | ||
// This is a hint to figure out if we need to call a browser method or | ||
// an element method. | ||
// "<" --> browser method | ||
// ">" --> element method | ||
var scopeHint; | ||
if(args && args[0] && typeof args[0] === 'string' && args[0].match(/^[<>]$/)) { | ||
scopeHint = args[0]; | ||
args = _.rest(args); | ||
} | ||
return this.then(function(res) { | ||
var el; | ||
// if the result is an element it has priority | ||
if(Element && res instanceof Element) { | ||
el = res; } | ||
// if we are within an element | ||
el = el || currentEl; | ||
// testing the water for the next call scope | ||
var isBrowserMethod = | ||
_.indexOf(promisedMethods, fname) >= 0; | ||
var isElementMethod = | ||
el && _.indexOf(elementPromisedMethods, fname) >= 0; | ||
if(!isBrowserMethod && !isElementMethod) { | ||
// doesn't look good | ||
throw new Error("Invalid method " + fname); | ||
} | ||
if(isBrowserMethod && isElementMethod) { | ||
// we need to resolve the conflict. | ||
if(scopeHint === '<') { | ||
isElementMethod = false; | ||
} else if(scopeHint === '>') { | ||
isBrowserMethod = false; | ||
} else if(fname.match(/element/) || (Element && args[0] instanceof Element)) { | ||
// method with element locators are browser scoped by default. | ||
// When an element is passed, we are also obviously in the global scope. | ||
isElementMethod = false; | ||
} else { | ||
// otherwise we stay in the element scope to allow sequential calls | ||
isBrowserMethod = false; | ||
} | ||
} | ||
if(isElementMethod) { | ||
// element method case. | ||
return el[fname].apply(el, args).then(function(res) { | ||
if(_.indexOf(elementChainableMethods, fname) >= 0) { | ||
// method like click, where no result is expected, we return | ||
// the element to make it chainable | ||
return el; | ||
} else { | ||
return res; // we have no choice but loosing the scope | ||
} | ||
}); | ||
}else{ | ||
// browser case. | ||
return _this[fname].apply(_this, args); | ||
} | ||
}); | ||
}; | ||
}); | ||
// transfering _enrich | ||
promise._enrich = function(target) { | ||
return _this._enrich(target, currentEl); | ||
}; | ||
// adding print error helper | ||
promise.printError = function() { | ||
return promise.catch(function(err) { | ||
console.log(err); | ||
throw err; | ||
}); | ||
}; | ||
} | ||
return obj; | ||
}; | ||
/** | ||
@@ -221,4 +220,4 @@ * Starts the chain (promised driver only) | ||
*/ | ||
promiseWebdriver.prototype.chain = promiseWebdriver.prototype.noop; | ||
promiseElement.prototype.chain = promiseElement.prototype.noop; | ||
PromiseWebdriver.prototype.chain = PromiseWebdriver.prototype.noop; | ||
PromiseElement.prototype.chain = PromiseElement.prototype.noop; | ||
@@ -230,3 +229,3 @@ /** | ||
*/ | ||
promiseWebdriver.prototype.resolve = function(promise) { | ||
PromiseWebdriver.prototype.resolve = function(promise) { | ||
var qPromise = new Q(promise); | ||
@@ -236,5 +235,5 @@ this._enrich(qPromise); | ||
}; | ||
promiseElement.prototype.resolve = function(promise) { | ||
PromiseElement.prototype.resolve = function(promise) { | ||
var qPromise = new Q(promise); | ||
this._enrich(qPromise, this.browser); | ||
this._enrich(qPromise); | ||
return qPromise; | ||
@@ -244,17 +243,14 @@ }; | ||
// used to by chai-as-promised and custom methods | ||
promiseWebdriver.prototype._enrich = function(target) { | ||
if(chainable) { enrich(target, this); } | ||
PromiseElement.prototype._enrich = function(target) { | ||
if(chainable) { return this.browser._enrich(target, this); } | ||
}; | ||
promiseElement.prototype._enrich = function(target) { | ||
if(chainable) { enrich(target, this.browser); } | ||
}; | ||
// used to wrap custom methods | ||
promiseWebdriver._wrapAsync = wrap; | ||
PromiseWebdriver._wrapAsync = wrap; | ||
// helper to allow easier promise debugging. | ||
promiseWebdriver.prototype._debugPromise = function() { | ||
PromiseWebdriver.prototype._debugPromise = function() { | ||
this.on('promise', function(context, method, args, status) { | ||
args = _.clone(args); | ||
if(context instanceof promiseWebdriver) { | ||
if(context instanceof PromiseWebdriver) { | ||
context = ''; | ||
@@ -280,3 +276,3 @@ } else { | ||
return promiseWebdriver; | ||
return PromiseWebdriver; | ||
}; |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"author": "Adam Christian <adam.christian@gmail.com>", | ||
@@ -13,0 +13,0 @@ "contributors": [ |
@@ -41,6 +41,8 @@ # WD.js | ||
Latest version is `0.2.5`. | ||
Many changes have been introduced in 0.2.x versions, please check | ||
[here](https://github.com/admc/wd/blob/master/doc/release-notes.md) for more details. | ||
### 0.2.3 caveats | ||
### caveats when upgrading to 0.2.3 | ||
- Most wait methods have been deprecated replaced by waitFor/waitForElement + asserters. See doc below, don't hesitate to add more asserters if you feel it is useful for others. | ||
@@ -514,1 +516,2 @@ - Manual monkey patching is not recommended anymore, there were some side use cases which were not easy to cover. | ||
var express = require('express'); | ||
var http = require('http'); | ||
@@ -8,3 +9,3 @@ function Express(rootDir, partials) { | ||
Express.prototype.start = function() { | ||
Express.prototype.start = function(done) { | ||
var _this = this; | ||
@@ -19,3 +20,2 @@ this.app = express(); | ||
content = _this.partials[req.query.p]; | ||
//console.log('got page', req.query.p, '-->', content ); | ||
} | ||
@@ -30,7 +30,8 @@ res.render('test-page', { | ||
this.app.use(express["static"](this.rootDir + '/public')); | ||
this.server = this.app.listen(env.EXPRESS_PORT); | ||
this.server = http.createServer(this.app); | ||
this.server.listen(env.EXPRESS_PORT, done); | ||
}; | ||
Express.prototype.stop = function() { | ||
return this.server.close(); | ||
Express.prototype.stop = function(done) { | ||
this.server.close(done); | ||
}; | ||
@@ -37,0 +38,0 @@ |
@@ -82,5 +82,5 @@ /* global sauceJobTitle, mergeDesired, midwayUrl, Express */ | ||
before(function() { | ||
before(function(done) { | ||
express = new Express( __dirname + '/assets' , partials); | ||
express.start(); | ||
express.start(done); | ||
}); | ||
@@ -99,4 +99,4 @@ | ||
after(function() { | ||
express.stop(); | ||
after(function(done) { | ||
express.stop(done); | ||
}); | ||
@@ -103,0 +103,0 @@ |
@@ -6,6 +6,6 @@ // spliting the test cause it takes too long, list of possible suffixes below | ||
require('../helpers/setup'); | ||
exports.test = function function_name (suffix, extraDesc, suffixPartials, criterias) { | ||
require('../helpers/setup'); | ||
describe('api-el-' + extraDesc + ' ' + env.ENV_DESC, function() { | ||
@@ -12,0 +12,0 @@ var partials = {}; |
@@ -30,5 +30,5 @@ /* global sauceJobTitle, mergeDesired, midwayUrl, Express */ | ||
before(function() { | ||
before(function(done) { | ||
express = new Express( __dirname + '/assets', partials); | ||
express.start(); | ||
express.start(done); | ||
}); | ||
@@ -52,4 +52,4 @@ | ||
after(function() { | ||
express.stop(); | ||
after(function(done) { | ||
express.stop(done); | ||
}); | ||
@@ -56,0 +56,0 @@ |
@@ -184,3 +184,6 @@ require('../helpers/setup'); | ||
.elementByCss("#theDiv input").then(function(el) { | ||
return el.type('hello').getValue().should.become("hello"); | ||
return el | ||
.type('hello') | ||
.getValue() | ||
.should.become("hello"); | ||
}); | ||
@@ -187,0 +190,0 @@ }); |
@@ -47,5 +47,5 @@ /* global sauceJobTitle, mergeDesired, midwayUrl, Express */ | ||
before(function() { | ||
before(function(done) { | ||
express = new Express( __dirname + '/assets', partials); | ||
express.start(); | ||
express.start(done); | ||
}); | ||
@@ -64,4 +64,4 @@ | ||
after(function() { | ||
express.stop(); | ||
after(function(done) { | ||
express.stop(done); | ||
}); | ||
@@ -68,0 +68,0 @@ |
@@ -12,6 +12,8 @@ /* global sauceJobTitle, mergeDesired, midwayUrl, Express */ | ||
var express; | ||
before(function(done) { | ||
express = new Express( __dirname + '/assets', partials ); | ||
express.start(done); | ||
}); | ||
before(function() { | ||
express = new Express( __dirname + '/assets', partials ); | ||
express.start(); | ||
browser = wd.promiseChainRemote(env.REMOTE_CONFIG); | ||
@@ -57,3 +59,2 @@ deferred.resolve(browser); | ||
after(function() { | ||
express.stop(); | ||
return browser | ||
@@ -65,3 +66,7 @@ .quit().then(function() { | ||
after(function(done) { | ||
express.stop(done); | ||
}); | ||
return deferred.promise; | ||
}; |
Sorry, the diff of this file is too big to display
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
Network access
Supply chain riskThis module accesses the network.
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
525791
107
9269
516
2