Socket
Socket
Sign inDemoInstall

wd

Package Overview
Dependencies
Maintainers
4
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wd - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

examples/mobile/appium_ios6_sauce.js

1

browser-scripts/safe-execute-async.js

@@ -6,4 +6,3 @@ var args = Array.prototype.slice.call(arguments, 0);

};
fargs.push(done);
wrap.apply(this, fargs);
var args = Array.prototype.slice.call(arguments, 0);
var code = args[0], fargs = args[1];
var wrap = function() {
return eval(code);
};
return wrap.apply(this, fargs);
var args = Array.prototype.slice.call(arguments, 0);
var condExpr = args[0], timeout = args[1],
var condExpr = args[0], timeout = args[1],
poll = args[2], cb = args[3];
// recursive implementation
var waitForConditionImpl = function(conditionExpr, limit, poll, cb) {
// timeout check
if ((new Date().getTime()) < limit) {
// condition check
var res = eval(conditionExpr);
if (res === true ) {
// condition ok
cb(res);
} else {
// wait for poll and try again
} else {
setTimeout(function() {
waitForConditionImpl(conditionExpr, limit, poll, cb);
}, poll);
}
}, poll);
}
} else {
// try one last time
res = eval(conditionExpr);

@@ -27,5 +19,3 @@ return cb(res);

};
// calling impl
var limit = (new Date().getTime()) + timeout;
var limit = (new Date().getTime()) + timeout;
waitForConditionImpl(condExpr, limit, poll, cb);

@@ -10,10 +10,10 @@ # Release Notes

- There are some changes in the way the element and webdriver classes are passed around
which may affect external wrappers. External wrappers should now subclass those 2 classes.
which may affect external wrappers. External wrappers should now subclass those 2 classes.
### 0.2.1
- New test suite using the promise chain api.
- `browser.Q` was moved to `wd.Q`.
### 0.2.2
### 0.2.2

@@ -24,16 +24,22 @@ - chai-as-promised v4 compatible.

Incompatibilities:
Incompatibilities:
- There is a new method to call, `wd.rewrap()`, to propagate async monkey
patching to promise. (see [here](https://github.com/admc/wd/blob/master/examples/promise/monkey.patch-with-async.js#L35) and the monkey patch section below)
- There is a new method to call, `wd.rewrap()`, to propagate async monkey patching to promise.
(see [here](https://github.com/admc/wd/blob/master/examples/promise/monkey.patch-with-async.js#L35)
and the monkey patch section in README) [Note: monkey patching and `rewrap` note recommended from 0.2.3].
- The chai-as-promised setup has changed in v4, look out for the `transferPromiseness` (Requires chai-as-promised 4.1.0 or greater)
line in the examples. (see [here](https://github.com/admc/wd/blob/master/examples/promise/chrome.js#L15))
line in the examples. (see [here](https://github.com/admc/wd/blob/master/examples/promise/chrome.js#L15)).
### 0.2.3 (In progress)
- http configuration enhancements + base url, see doc [here](https://github.com/admc/wd#http-configuration--base-url).
### 0.2.3
- Http configuration enhancements + base url, see doc [here](https://github.com/admc/wd#http-configuration--base-url).
- `waitFor`, `waitForElement` and asserters replacing existing wait methods.
- addPromiseChainMethod/addPromiseMethod/addAsyncMethod/removeMethod replacing monkey patching.
Please refer to the add method section in README.
- `addPromiseChainMethod`/`addPromiseMethod`/`addAsyncMethod`/`removeMethod` replacing monkey patching
(Please refer to the add method section in README).
- Support for external promise libraries.
- New saveScreenshot method.
### 0.2.4 (in progress)
- bugfix: android safeExecute.
- bugfix: passing argument to execute.
- bugfix: setOrientation.
- migrating from string.js to underscore.string (todo).

@@ -1,2 +0,2 @@

var S = require('string');
var _ = require('./lodash');

@@ -16,3 +16,3 @@ function Asserter(_assert){

if(err) { return cb(err); }
var satisfied = text && S(text).trim().length >0;
var satisfied = text && _(text).trim().value().length >0;
cb(null, satisfied, satisfied? text : undefined);

@@ -33,3 +33,3 @@ });

if(err) { return cb(err); }
var satisfied = text && S(text).contains(content);
var satisfied = text && _(text).includeString(content).value();
cb(null, satisfied, satisfied? text : undefined);

@@ -72,3 +72,3 @@ });

* jsConditionExpr: js script expression, should evaluate as boolean.
*
*
* @asserter

@@ -75,0 +75,0 @@ */

@@ -1,2 +0,2 @@

var _ = require('lodash');
var _ = require('./lodash');

@@ -3,0 +3,0 @@ var httpConfig = {

var async = require("async");
var _ = require("lodash");
var _ = require("./lodash");

@@ -4,0 +4,0 @@ var deprecatedChain ={};

//Element object
//Wrapper around browser methods
var __slice = Array.prototype.slice;
var _ = require("lodash")
var _ = require("./lodash")
, utils = require("./utils.js")

@@ -6,0 +6,0 @@ , fs = require("fs");

@@ -8,3 +8,3 @@ var __slice = Array.prototype.slice;

var config = require('./config');
var _ = require("lodash");
var _ = require("./lodash");
var Q = require('q');

@@ -143,3 +143,3 @@

function addAsyncMethod(name, method) {
Webdriver.prototype[name] = method;
Webdriver.prototype[name] = method;
PromiseWebdriver.prototype[name] = PromiseWebdriver._wrapAsync(method);

@@ -152,3 +152,3 @@ PromiseChainWebdriver.prototype[name] = PromiseChainWebdriver._wrapAsync(method);

delete PromiseWebdriver.prototype[name];
delete PromiseChainWebdriver.prototype[name];
delete PromiseChainWebdriver.prototype[name];
}

@@ -189,4 +189,4 @@

rewrap: function() {
deprecator.warn('rewrap',
'rewrap has been deprecated, use addAsyncMethod instead.');
deprecator.warn('rewrap',
'rewrap has been deprecated, use addAsyncMethod instead.');
wrap();

@@ -207,3 +207,3 @@ },

getHttpConfig: function() { return _(config.httpConfig).clone(); },
// deprecation

@@ -214,4 +214,4 @@ /**

* @wd
*/
showHideDeprecation: deprecator.showHideDeprecation.bind(deprecator),
*/
showHideDeprecation: deprecator.showHideDeprecation.bind(deprecator),

@@ -223,3 +223,3 @@ // add/remove methods

* @wd
*/
*/
addAsyncMethod: addAsyncMethod,

@@ -230,3 +230,3 @@ /**

* @wd
*/
*/
addPromiseMethod: addPromiseMethod,

@@ -237,3 +237,3 @@ /**

* @wd
*/
*/
addPromiseChainMethod: addPromiseChainMethod,

@@ -244,5 +244,5 @@ /**

* @wd
*/
*/
removeMethod: removeMethod,
// Useful stuff

@@ -249,0 +249,0 @@ Asserter: require('./asserters').Asserter,

@@ -1,5 +0,5 @@

var __slice = Array.prototype.slice,
Q = require('q'),
_ = require('lodash'),
EventEmitter = require('events').EventEmitter,
var __slice = Array.prototype.slice,
Q = require('q'),
_ = require('./lodash'),
EventEmitter = require('events').EventEmitter,
slice = Array.prototype.slice.call.bind(Array.prototype.slice),

@@ -17,3 +17,3 @@ utils = require('./utils');

return _(Obj).functions().filter(function(fname) {
return !fname.match('^toString$|^_') &&
return !fname.match('^toJSON$|^toString$|^_') &&
!EventEmitter.prototype[fname];

@@ -20,0 +20,0 @@ }).value();

var Args = require("vargs").Constructor;
var _ = require('lodash');
var _ = require('./lodash');

@@ -71,8 +71,9 @@ var varargs = exports.varargs = function(args) {

console.warn(message);
}
}
}
};
// Android doesn't like cariage return
exports.inlineJs = function(script) {
return script.replace(/[\r\n]/g,'').trim();
};

@@ -10,3 +10,3 @@ {

],
"version": "0.2.3",
"version": "0.2.4",
"author": "Adam Christian <adam.christian@gmail.com>",

@@ -58,3 +58,3 @@ "contributors": [

"tmp": "0.0.21",
"string": "~1.6.1"
"underscore.string": "~2.3.3"
},

@@ -61,0 +61,0 @@ "devDependencies": {

@@ -41,3 +41,3 @@ # WD.js

Many changes have been introduced in 0.2.x versions, please check
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.

@@ -182,3 +182,3 @@

[åfull jsonwire mapping](https://github.com/admc/wd/blob/master/doc/jsonwire-full-mapping.md)
[full jsonwire mapping](https://github.com/admc/wd/blob/master/doc/jsonwire-full-mapping.md)

@@ -266,6 +266,6 @@ ### JsonWireProtocol

With the promise chain api the method from the `browser` prototype and the
With the promise chain api the method from the `browser` prototype and the
`element` prototype are all available within the `browser` instance, so it might
be confusing at first. However we tried to keep the logic as simple as possible
using the principles below:
be confusing at first. However we tried to keep the logic as simple as possible
using the principles below:

@@ -279,3 +279,3 @@ - There is no state passed between calls, except for what the method returns.

If you need to do something more complicated, like reusing an element for 2 calls, then
If you need to do something more complicated, like reusing an element for 2 calls, then
can either Q promise functionnality (like then, Q.all or Q sequences), or retrieve your

@@ -291,3 +291,3 @@ element twice (since the promise chain api is very terse, this is usually acceptable).

- `browser.waitFor(asserter, timeout, pollFreq, cb) -> cb(err, value)`: generic wait method, the return value is provided by the asserter when the condition is satisfied.
- `browser.waitForElementBy???(value ,asserter, timeout, pollFreq, cb) -> cb(err, el)`: waits for a element then a
- `browser.waitForElementBy???(value ,asserter, timeout, pollFreq, cb) -> cb(err, el)`: waits for a element then a
condition, then returns the element.

@@ -312,5 +312,5 @@ - `browser.waitForConditionInBrowser(conditionExpr, timeout, pollFreq, cb) -> cb(err, boolean)`: waits for a js condition within a browser, then returns a boolean.

return promise; // promise resolved with the wait_for return value.
// Promise asserter should throw errors marked with `err.retriable=true`
// when the condition is not satisfied.
// Promise asserter should throw errors marked with `err.retriable=true`
// when the condition is not satisfied.
}

@@ -332,5 +332,5 @@ );

If you are only using the promise chain api, you should probably stick with `wd.addPromiseChainMethod(name, method)`.
If you are only using the promise chain api, you should probably stick with `wd.addPromiseChainMethod`.
You may remove a custom method with `wd.removeMethod(name)`. Not sure why you would want to do that, but that will remove the method from the 3 prototypes.
Custom methods may be removed with `wd.removeMethod(name)`. That will remove the method from the 3 prototypes.

@@ -353,4 +353,4 @@ Please refer to the following examples:

The `browser` and `element` object are not themselves promises (cause that would lead to chaos), so you
cannot call Q core methods on them. However you may call one of the method below to initiate the promise
The `browser` and `element` object are not themselves promises (cause that would lead to chaos), so you
cannot call Q core methods on them. However you may call one of the method below to initiate the promise
chain:

@@ -381,3 +381,3 @@

Http behaviour and base url may be configured via the `configureHttp` method as
Http behaviour and base url may be configured via the `configureHttp` method as
in the code below:

@@ -400,7 +400,7 @@

});
```
```
- timeout: http timeout in ms, default is `undefined` (uses the server timeout,
- timeout: http timeout in ms, default is `undefined` (uses the server timeout,
usually 60 seconds). Use `'default'` or `undefined` for server default.
- retries: Number of reconnection attempts in case the connection is dropped.
- retries: Number of reconnection attempts in case the connection is dropped.
Default is `3`. Pass `0` or `always` to keep trying. Pass `-1` or `never` to disable.

@@ -435,2 +435,21 @@ - retryDelay: the number of ms to wait before reconnecting. Default is `15`.

## Working with mobile device emulators
It is possible to use `wd` to test mobile devices using either Selenium or Appium. However
in either case the full JsonWire protocol is not supported (or is buggy).
Examples [here](https://github.com/admc/wd/tree/master/examples/mobile).
### Selenium
Both Android (using AndroidDriver) and ios (using ios-driver) are supported, locally or using
Sauce Labs cloud.
### Appium
Android is only supported locally.
ios6 is supported locally or using Sauce Labs cloud. There is an issue with ios7, the Appium
team is working to solve it.
## Run the tests!

@@ -459,3 +478,3 @@

# Set the following env variales: SAUCE_USERNAME and SAUCE_ACCESS_KEY
# Set the following env variales: SAUCE_USERNAME and SAUCE_ACCESS_KEY

@@ -504,3 +523,3 @@ # Start Sauce Sonnect:

[test coverage](http://admc.io/wd/istanbul/coverage/lcov-report/index.html)
[test coverage](http://admc.io/wd/istanbul/coverage/lcov-report/lib/index.html)
var Mocha = require('mocha'),
fs = require('fs'),
path = require('path'),
_ = require('lodash'),
_ = require('./lodash'),
Q = require('Q');

@@ -6,0 +6,0 @@

@@ -0,20 +1,21 @@

GLOBAL._ = require('../../lib/lodash');
var env = GLOBAL.env = {};
var S = require('string');
var toBoolean = function(str) {
return S(str).toBoolean() || S(S(str).toInt()).toBoolean();
return _(str).toBoolean().value();
};
env.VERBOSE = toBoolean(process.env.VERBOSE);
env.BASE_TIME_UNIT = S(process.env.BASE_TIME_UNIT || 500).toInt();
env.TIMEOUT = S(process.env.TIMEOUT || 60000).toInt();
env.BASE_TIME_UNIT = _(process.env.BASE_TIME_UNIT || 500).toNumber().value();
env.TIMEOUT = _(process.env.TIMEOUT || 60000).toNumber().value();
env.SHORT = toBoolean(process.env.SHORT);
env.HTTP_CONFIG = {};
if(process.env.HTTP_TIMEOUT)
{ env.HTTP_CONFIG.timeout = S(process.env.HTTP_TIMEOUT).toInt(); }
{ env.HTTP_CONFIG.timeout = _(process.env.HTTP_TIMEOUT).toNumber().value(); }
if(process.env.HTTP_RETRIES)
{ env.HTTP_CONFIG.retries = S(process.env.HTTP_RETRIES).toInt(); }
{ env.HTTP_CONFIG.retries = _(process.env.HTTP_RETRIES).toNumber().value(); }
if(process.env.HTTP_RETRY_DELAY)
{ env.HTTP_CONFIG.retryDelay = S(process.env.HTTP_RETRY_DELAY).toInt(); }
{ env.HTTP_CONFIG.retryDelay = _(process.env.HTTP_RETRY_DELAY).toNumber().value(); }

@@ -25,56 +26,24 @@ env.DEBUG_CONNECTION = process.env.DEBUG_CONNECTION;

env.BROWSER = process.env.BROWSER || 'chrome';
env.BROWSER_SKIP = env.BROWSER;
env.MULTI = false;
if(env.BROWSER === 'multi') {
env.BROWSER = 'chrome';
env.MULTI = true;
}
env.DESIRED = process.env.DESIRED ? JSON.parse(process.env.DESIRED) :
{browserName: env.BROWSER};
if(env.BROWSER === 'android' || env.BROWSER === 'android_tablet'){
env.ANDROID = true;
env.DESIRED = {
'browserName': 'android',
'version': '4.0',
'platform': 'Linux',
'device-type': 'tablet',
'device-orientation': 'portrait', // 'landscape'
};
if(env.BROWSER === 'multi') {
env.DESIRED = {browserName: 'chrome'};
}
if(env.BROWSER === 'android_phone'){
env.ANDROID = true;
env.DESIRED = {
'browserName': 'android',
'version': '4.0',
'platform': 'Linux',
'device-orientation': 'portrait', // 'landscape'
};
}
require('./mobile_env');
if(env.BROWSER === 'ios' || env.BROWSER === 'ipad'){
env.IOS = true;
env.DESIRED = {
'browserName': 'ipad',
'version': '6.1',
'platform': 'OS X 10.8',
'device-orientation': 'portrait', // 'landscape'
};
}
env.EXPRESS_PORT = _(process.env.EXPRESS_PORT || 3000).toNumber().value();
if(env.BROWSER === 'iphone'){
env.IOS = true;
env.DESIRED = {
'browserName': 'iphone',
'version': '6.1',
'platform': 'OS X 10.8',
'device-orientation': 'portrait', // 'landscape'
};
}
env.EXPRESS_PORT = S(process.env.EXPRESS_PORT || 3000).toInt();
env.MIDWAY_ROOT_HOST = '127.0.0.1';
if(env.ANDROID){
env.MIDWAY_ROOT_HOST = '10.0.2.2';
env.TIMEOUT = 300000;

@@ -94,11 +63,7 @@ }

env.TRAVIS = true;
console.log("Travis environment detected.");
console.log("TRAVIS_BUILD_NUMBER --> ", env.TRAVIS_BUILD_NUMBER);
console.log("TRAVIS_JOB_NUMBER --> ", env.TRAVIS_JOB_NUMBER);
console.log("TRAVIS_JOB_ID --> ", env.TRAVIS_JOB_ID);
}
if(env.SAUCE){
env.BASE_TIME_UNIT = S(process.env.BASE_TIME_UNIT || 3000).toInt();
env.TIMEOUT = S(process.env.TIMEOUT || 600000).toInt();
env.BASE_TIME_UNIT = _(process.env.BASE_TIME_UNIT || 3000).toNumber().value();
env.TIMEOUT = _(process.env.TIMEOUT || 600000).toNumber().value();

@@ -105,0 +70,0 @@ env.SAUCE_JOB_ID =

var express = require('express');
function Express(rootDir) {
function Express(rootDir, partials) {
this.rootDir = rootDir;
this.partials = {};
this.partials = partials;
}
Express.prototype.start = function() {
var _this = this;
this.app = express();

@@ -13,10 +14,10 @@ this.app.set('view engine', 'hbs');

var partials = this.partials;
this.app.get('/test-page', function(req, res) {
var content = '';
if(req.query.p){
content = partials[req.query.p];
content = _this.partials[req.query.p];
//console.log('got page', req.query.p, '-->', content );
}
res.render('test-page', {
testSuite: req.query.ts,
testSuite: req.query.ts? req.query.ts.replace(/\@[\w\-]+/g,'') : '',
testTitle: (req.query.c? req.query.c + ' - ': '') + req.query.p,

@@ -23,0 +24,0 @@ content: content

require('./env');
GLOBAL._ = require('lodash');
GLOBAL.wd = require('../../lib/main');
var utils = require('../../lib/utils');
if( env.TRAVIS ){
console.log("Travis environment detected.");
console.log("TRAVIS_BUILD_NUMBER --> ", env.TRAVIS_BUILD_NUMBER);
console.log("TRAVIS_JOB_NUMBER --> ", env.TRAVIS_JOB_NUMBER);
console.log("TRAVIS_JOB_ID --> ", env.TRAVIS_JOB_ID);
}
// monkey patching
wd.addAsyncMethod(
'configureLogging',
'configureLogging',
function (done){

@@ -31,3 +37,3 @@ if(env.VERBOSE) {

GLOBAL.midwayUrl = function(testSuite, cat, title){
if(!title) {
if(!title) {
title = cat;

@@ -64,2 +70,9 @@ cat = undefined;

GLOBAL.prepareJs = function(script) {
if(env.ANDROID){
script = utils.inlineJs(script);
}
return script;
};
GLOBAL.Q = GLOBAL.wd.Q;

@@ -66,0 +79,0 @@

@@ -42,3 +42,3 @@ /* global sauceJobTitle, mergeDesired, midwayUrl, Express */

.text(el);
}
}
};

@@ -52,5 +52,5 @@

.then(function() {
return _this.elementById(id);
return _this.elementById(id);
});
} ,

@@ -62,9 +62,9 @@ sleepAndText: function(el) {

.then(function() {
return _this.text(el);
return _this.text(el);
});
}
}
};
var allExtraMethodNames = _.union(
_(extraAsyncMethods).keys().value(),
_(extraAsyncMethods).keys().value(),
_(extraPromiseChainMethods).keys().value(),

@@ -82,5 +82,7 @@ _(extraPromiseNoChainMethods).keys().value()

var express = new Express( __dirname + '/assets' );
var partials = {};
var express;
before(function() {
express = new Express( __dirname + '/assets' , partials);
express.start();

@@ -92,7 +94,7 @@ });

});
afterEach(function() {
_(allExtraMethodNames).each(function(name) {
wd.removeMethod(name);
});
wd.removeMethod(name);
});
noExtraMethodCheck();

@@ -136,3 +138,3 @@ });

express.partials['wd.addPromisedMethod (chain)'] =
partials['wd.addPromisedMethod (chain)'] =
'<div id="theDiv">Hello World!</div>';

@@ -143,3 +145,3 @@ it('wd.addPromisedMethod (chain)', function() {

});
browser = newPromiseChainRemote();

@@ -157,3 +159,3 @@ return initAndGet(this, 'pc/1').then(function() {

express.partials['wd.addPromisedMethod (no-chain)'] =
partials['wd.addPromisedMethod (no-chain)'] =
'<div id="theDiv">Hello World!</div>';

@@ -164,3 +166,3 @@ it('wd.addPromisedMethod (no-chain)', function() {

});
browser = newPromiseChainRemote();

@@ -178,3 +180,3 @@ return initAndGet(this, 'pc/2').then(function() {

express.partials['wd.addAsyncMethod'] =
partials['wd.addAsyncMethod'] =
'<div id="theDiv">Hello World!</div>';

@@ -216,4 +218,4 @@ it('wd.addAsyncMethod', function() {

.configureLogging()
.then(function() {
return browser.init(mergeDesired(env.DESIRED, env.SAUCE? sauceExtra : null ));
.then(function() {
return browser.init(mergeDesired(env.DESIRED, env.SAUCE? sauceExtra : null ));
}).then(function() {

@@ -224,3 +226,3 @@ return browser.get( midwayUrl(

that.runnable().title)
);
);
});

@@ -237,3 +239,3 @@ }

express.partials['wd.addPromisedMethod'] =
partials['wd.addPromisedMethod'] =
'<div id="theDiv">Hello World!</div>';

@@ -244,3 +246,3 @@ it('wd.addPromisedMethod', function() {

});
browser = newPromiseRemote();

@@ -255,3 +257,3 @@ return initAndGet(this, 'pnc/1').then(function() {

}).then(function(el){
return browser.sleepAndText(el).should.become("Hello World!");
return browser.sleepAndText(el).should.become("Hello World!");
});

@@ -261,3 +263,3 @@ });

express.partials['wd.addAsyncMethod'] =
partials['wd.addAsyncMethod'] =
'<div id="theDiv">Hello World!</div>';

@@ -277,3 +279,3 @@ it('wd.addAsyncMethod', function() {

}).then(function(el){
return browser.sleepAndText(el).should.become("Hello World!");
return browser.sleepAndText(el).should.become("Hello World!");
});

@@ -302,3 +304,3 @@ });

if(err) { return cb(err); }
browser.get(
browser.get(
midwayUrl(

@@ -311,3 +313,3 @@ that.runnable().parent.parent.title,

);
});
});
});

@@ -320,10 +322,10 @@ }

if(err) { return done(err); }
if(env.SAUCE)
if(env.SAUCE)
{ browser.sauceJobStatus(_this.currentTest.state === 'passed', done); }
else
{ done(); }
{ done(); }
});
});
express.partials['wd.addAsyncMethod'] =
partials['wd.addAsyncMethod'] =
'<div id="theDiv">Hello World!</div>';

@@ -330,0 +332,0 @@ it('wd.addAsyncMethod', function(done) {

require('../helpers/setup');
describe('api-el ' + env.ENV_DESC, function() {
var partials = {};
var ctx = require('./midway-base')(this),
express = ctx.express,
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });
express.partials['browser.element'] =
partials['browser.element'] =
'<div name="theDiv">Hello World!</div>';

@@ -19,3 +18,3 @@ it('browser.element', function() {

express.partials['browser.elementOrNull'] =
partials['browser.elementOrNull'] =
'<div name="theDiv">Hello World!</div>';

@@ -28,3 +27,3 @@ it('browser.elementOrNull', function() {

express.partials['browser.elementIfExists'] =
partials['browser.elementIfExists'] =
'<div name="theDiv">Hello World!</div>';

@@ -37,3 +36,3 @@ it('browser.elementIfExists', function() {

express.partials['browser.hasElement'] =
partials['browser.hasElement'] =
'<div name="theDiv">Hello World!</div>';

@@ -46,7 +45,7 @@ it('browser.hasElement', function() {

express.partials['browser.waitForElement'] =
partials['browser.waitForElement'] =
'<div id="theDiv"></div>';
it('browser.waitForElement', function() {
it('browser.waitForElement @skip-ios @skip-android', function() {
return browser
.executeAsync(
.executeAsync( prepareJs(
'var args = Array.prototype.slice.call( arguments, 0 );\n' +

@@ -57,3 +56,3 @@ 'var done = args[args.length -1];\n' +

'}, arguments[0]);\n' +
'done();\n',
'done();\n' ),
[env.BASE_TIME_UNIT]

@@ -71,7 +70,7 @@ )

express.partials['browser.waitForVisible'] =
partials['browser.waitForVisible'] =
'<div id="theDiv"></div>';
it('browser.waitForVisible', function() {
it('browser.waitForVisible @skip-ios @skip-android', function() {
return browser
.executeAsync(
.executeAsync( prepareJs(
'var args = Array.prototype.slice.call( arguments, 0 );\n' +

@@ -84,3 +83,3 @@ 'var done = args[args.length -1];\n' +

'}, arguments[0]);\n' +
'done();\n',
'done();\n' ),
[env.BASE_TIME_UNIT]

@@ -99,3 +98,3 @@ )

express.partials['browser.elements'] =
partials['browser.elements'] =
'<div>\n' +

@@ -113,3 +112,3 @@ ' <div name="elementsByName">Hello World!</div>\n' +

express.partials['browser.getAttribute'] =
partials['browser.getAttribute'] =
'<div id="weatherDiv" weather="sunny">Hi</div>';

@@ -126,3 +125,3 @@ it('browser.getAttribute', function() {

express.partials['browser.getTagName'] =
partials['browser.getTagName'] =
'<div id="theDiv"><input type="text"><a href="#">a1</a></div>';

@@ -132,8 +131,8 @@ it('browser.getTagName', function() {

.elementByCss('#theDiv input').then(function(el) {
return browser.getTagName(el).should.become("input");
return browser.getTagName(el).should.eventually.match(/^input$/i);
})
.elementByCss('#theDiv a').getTagName().should.become("a");
.elementByCss('#theDiv a').getTagName().should.eventually.match(/^a$/i);
});
express.partials['browser.getValue'] =
partials['browser.getValue'] =
'<div id="theDiv">\n' +

@@ -155,3 +154,3 @@ ' <input class="input-text" type="text" value="Hello getValueTest!">\n' +

express.partials['browser.getComputedCss'] =
partials['browser.getComputedCss'] =
'<div id="theDiv">\n' +

@@ -166,7 +165,7 @@ ' <a href="#">a1</a>\n' +

}).elementByCss('#theDiv a').getComputedCss('color')
.should.eventually.match(/rgba/);
.should.eventually.match(/rgb/);
});
express.partials['browser.text'] =
partials['browser.text'] =
'<div id="theDiv"><div>text content</div></div>\n';

@@ -199,3 +198,3 @@ it('browser.text', function() {

express.partials['browser.textPresent'] =
partials['browser.textPresent'] =
'<div id="theDiv">weather is sunny</div>\n';

@@ -202,0 +201,0 @@ it('browser.textPresent', function() {

@@ -6,3 +6,3 @@ // spliting the test cause it takes too long, list of possible suffixes below

exports.test = function function_name (suffix, extraDesc, partials, criterias) {
exports.test = function function_name (suffix, extraDesc, suffixPartials, criterias) {

@@ -12,10 +12,9 @@ require('../helpers/setup');

describe('api-el-' + extraDesc + ' ' + env.ENV_DESC, function() {
var partials = {};
var ctx = require('./midway-base')(this),
express = ctx.express,
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });
var elementFuncName = 'element' + suffix;
express.partials['browser.' + elementFuncName] = partials.one;
partials['browser.' + elementFuncName] = suffixPartials.one;
it('browser.' + elementFuncName, function() {

@@ -29,3 +28,3 @@ return Q.all([

var elementFuncNameOrNull = 'element' + suffix + 'OrNull';
express.partials['browser.' + elementFuncNameOrNull] = partials.one;
partials['browser.' + elementFuncNameOrNull] = suffixPartials.one;
it('browser.' + elementFuncNameOrNull, function() {

@@ -38,3 +37,3 @@ return browser

var elementFuncNameIfExists = 'element' + suffix + 'IfExists';
express.partials['browser.' + elementFuncNameIfExists] = partials.one;
partials['browser.' + elementFuncNameIfExists] = suffixPartials.one;
it('browser.' + elementFuncNameIfExists, function() {

@@ -47,3 +46,3 @@ return browser

var hasElementFuncName = 'hasElement' + suffix;
express.partials['browser.' + hasElementFuncName] = partials.one;
partials['browser.' + hasElementFuncName] = suffixPartials.one;
it('browser.' + hasElementFuncName, function() {

@@ -56,5 +55,5 @@ return browser

var waitForElementFuncName = 'waitForElement' + suffix;
express.partials['browser.' + waitForElementFuncName] =
'<div id="theDiv"></div>';
partials['browser.' + waitForElementFuncName] = '<div id="theDiv"></div>';
it('browser.' + waitForElementFuncName, function() {
var startMs = Date.now();
return browser

@@ -68,5 +67,11 @@ .executeAsync(

'done();\n',
[partials.child, env.BASE_TIME_UNIT]
[suffixPartials.child, env.BASE_TIME_UNIT]
)
[elementFuncName](criterias.child).should.be.rejectedWith(/status: 7/)
.then(function() {
// if selenium was too slow skip the test.
if(Date.now() - startMs < env.BASE_TIME_UNIT){
return browser[elementFuncName](criterias.child)
.should.be.rejectedWith(/status: 7/);
}
})
[waitForElementFuncName](criterias.child, 2 * env.BASE_TIME_UNIT)

@@ -82,4 +87,3 @@ .should.be.fulfilled

var waitForVisibleFuncName = 'waitForVisible' + suffix;
express.partials['browser.' + waitForVisibleFuncName] =
'<div id="theDiv"></div>';
partials['browser.' + waitForVisibleFuncName] = '<div id="theDiv"></div>';
it('browser.' + waitForVisibleFuncName, function() {

@@ -96,3 +100,3 @@ return browser

'done();\n',
[partials.child, env.BASE_TIME_UNIT]
[suffixPartials.child, env.BASE_TIME_UNIT]
)

@@ -110,3 +114,3 @@ [elementFuncName](criterias.child).should.eventually.exist

var elementsFuncName = 'elements' + suffix;
express.partials['browser.' + elementsFuncName] = partials.several;
partials['browser.' + elementsFuncName] = suffixPartials.several;
it('browser.' + elementsFuncName, function() {

@@ -113,0 +117,0 @@ return browser

require('../helpers/setup');
describe('api-nav ' + env.ENV_DESC, function() {
var partials = {};
var ctx = require('./midway-base')(this),
express = ctx.express,
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });

@@ -15,4 +14,2 @@ if(!env.SAUCE){ // page timeout seems to be disabled in sauce

.setPageLoadTimeout(env.BASE_TIME_UNIT / 2)
.setPageLoadTimeout(env.BASE_TIME_UNIT / 2)
.get( env.MIDWAY_ROOT_URL + '/test-page')
.setPageLoadTimeout(defaultTimeout);

@@ -22,3 +19,3 @@ });

express.partials['browser.get'] =
partials['browser.get'] =
'<div name="theDiv">Hello World!</div>';

@@ -52,3 +49,3 @@ it('browser.get', function() {

express.partials['browser.setImplicitWaitTimeout'] =
partials['browser.setImplicitWaitTimeout'] =
'<div id="setWaitTimeout"></div>';

@@ -59,6 +56,6 @@ it('browser.setImplicitWaitTimeout', function() {

.setImplicitWaitTimeout(0)
.execute(
.execute( prepareJs(
'setTimeout(function() {\n' +
'$("#setWaitTimeout").html("<div class=\\"child\\">a child</div>");\n' +
'}, arguments[0]);', [env.BASE_TIME_UNIT])
'}, arguments[0]);' ), [env.BASE_TIME_UNIT])
.elementByCss('#setWaitTimeout .child').should.be.rejectedWith(/status\: 7/)

@@ -70,7 +67,7 @@ .setImplicitWaitTimeout(2 * env.BASE_TIME_UNIT)

express.partials['browser.clickElement'] =
partials['browser.clickElement'] =
'<div id="theDiv"><a href="#">not clicked</a></div>\n';
it('browser.clickElement', function() {
return browser
.execute(
.execute( prepareJs(
'jQuery( function() {\n' +

@@ -82,3 +79,3 @@ ' a = $(\'#theDiv a\');\n' +

' });\n' +
'});\n'
'});\n')
)

@@ -94,47 +91,57 @@ .elementByCss("#theDiv a").then(function(el) {

express.partials['browser.moveTo'] =
partials['browser.moveTo'] =
'<div id="theDiv">\n' +
' <a class="a1" href="#">a1</a><br>\n' +
' <a class="a2" href="#">a2</a><br>\n' +
' <div class="div1" href="#">div 1</div>\n' +
' <div class="div2" href="#">div 1</div>\n' +
' <div class="current"></div>\n' +
'</div>\n';
it('browser.moveTo', function() {
return browser
.execute(
'jQuery( function() {\n' +
' a1 = $(\'#theDiv .a1\');\n' +
' a2 = $(\'#theDiv .a2\');\n' +
' current = $(\'#theDiv .current\');\n' +
' a1.hover(function() {\n' +
' current.html(\'a1\');\n' +
' });\n' +
' a2.hover(function() {\n' +
' current.html(\'a2\');\n' +
' });\n' +
'});\n'
)
.elementByCss('#theDiv .current').text().should.become('')
.elementByCss('#theDiv .a1').then(function(a1) {
return browser
.moveTo(a1)
.elementByCss('#theDiv .current').text().should.become('a1');
})
.elementByCss('#theDiv .a2').then(function(a2) {
return browser
.moveTo(a2)
.elementByCss('#theDiv .current').text().should.become('a2');
})
.elementByCss('#theDiv .a1').then(function(a1) {
return browser
.moveTo(a1)
.elementByCss('#theDiv .current').text().should.become('a1');
});
// todo: add moveTo to element
it('browser.moveTo @skip-ios @skip-android', function() {
if(true || env.BROWSER === 'explorer') {
// cannot get hover to work in explorer
return browser
.elementByCss('#theDiv .div1').then(function(div1) {
return browser
.moveTo(div1).should.be.fulfilled;
})
.elementByCss('#theDiv .div1')
.moveTo().should.be.fulfilled;
} else {
return browser
.execute( prepareJs(
'jQuery( function() {\n' +
' var div1 = $(\'#theDiv .div1\');\n' +
' var div2 = $(\'#theDiv .div2\');\n' +
' var current = $(\'#theDiv .current\');\n' +
' div1.hover(function() {\n' +
' current.html(\'div 1\');\n' +
' });\n' +
' div2.hover(function() {\n' +
' current.html(\'div 2\');\n' +
' });\n' +
'});\n')
)
.elementByCss('#theDiv .current').text().should.become('')
.elementByCss('#theDiv .div1').then(function(div1) {
return browser
.moveTo(div1)
.elementByCss('#theDiv .current').text().should.become('div 1');
})
.elementByCss('#theDiv .div2').then(function(div2) {
return browser
.moveTo(div2)
.elementByCss('#theDiv .current').text().should.become('div 2');
})
.elementByCss('#theDiv .div1').then(function(div1) {
return browser
.moveTo(div1)
.elementByCss('#theDiv .current').text().should.become('div 1');
});
}
});
express.partials['browser.buttonDown/browser.buttonUp'] =
partials['browser.buttonDown/browser.buttonUp'] =
'<div id="theDiv"><a>hold me</a><div class="res"></div></div>\n';
it('browser.buttonDown/browser.buttonUp', function() {
it('browser.buttonDown/browser.buttonUp @skip-ios @skip-android', function() {
return browser
.execute(
.execute( prepareJs(
'jQuery( function() {\n' +

@@ -150,3 +157,3 @@ ' a = $(\'#theDiv a\');\n' +

' });\n' +
'});\n'
'});\n')
)

@@ -169,3 +176,3 @@ .elementByCss('#theDiv .res').text().should.become('')

express.partials['browser.click'] =
partials['browser.click'] =
'<div id="theDiv">\n' +

@@ -175,5 +182,5 @@ ' <div class="numOfClicks">not clicked</div>\n' +

'</div>\n';
it('browser.click', function() {
it('browser.click @skip-ios @skip-android', function() {
return browser
.execute(
.execute( prepareJs(
'jQuery( function() {\n' +

@@ -192,3 +199,3 @@ ' var numOfClick = 0;\n' +

' });\n' +
'});\n'
'});\n')
)

@@ -218,9 +225,9 @@ .elementByCss('#theDiv .numOfClicks').text().should.become('not clicked')

express.partials['browser.doubleclick'] =
partials['browser.doubleclick'] =
'<div id="theDiv">\n' +
' <div>not clicked</div>\n' +
'</div>\n';
it('browser.doubleclick', function() {
it('browser.doubleclick @skip-ios @skip-android', function() {
return browser
.execute(
.execute( prepareJs(
'jQuery( function() {\n' +

@@ -231,3 +238,3 @@ ' div = $(\'#theDiv div\');\n' +

' });\n' +
'});\n'
'});\n')
)

@@ -243,3 +250,3 @@ .elementByCss('#theDiv div').text().should.become('not clicked')

express.partials['browser.clear'] =
partials['browser.clear'] =
'<div id="theDiv">\n' +

@@ -265,7 +272,7 @@ ' <input type="text" value="not cleared">\n' +

express.partials['browser.acceptAlert'] =
partials['browser.acceptAlert'] =
'<div id="theDiv"><a>click me</a></div>\n';
it('browser.acceptAlert', function() {
it('browser.acceptAlert @skip-ios @skip-android', function() {
return browser
.execute(
.execute( prepareJs(
'jQuery( function() {\n' +

@@ -277,3 +284,3 @@ ' a = $(\'#theDiv a\');\n' +

' });\n' +
'});\n'
'});\n')
)

@@ -284,7 +291,7 @@ .elementByCss("#theDiv a").click()

express.partials['browser.dismissAlert'] =
partials['browser.dismissAlert'] =
'<div id="theDiv"><a>click me</a></div>\n';
it('browser.dismissAlert @skip-chrome', function() {
it('browser.dismissAlert @skip-chrome @skip-ios @skip-android', function() {
return browser
.execute(
.execute( prepareJs(
'jQuery( function() {\n' +

@@ -296,3 +303,3 @@ ' a = $(\'#theDiv a\');\n' +

' });\n' +
'});\n'
'});\n')
)

@@ -299,0 +306,0 @@ .elementByCss("#theDiv a").click()

@@ -9,9 +9,8 @@ require('../helpers/setup');

describe('api-various ' + env.ENV_DESC, function() {
var partials = {};
var ctx = require('./midway-base')(this),
express = ctx.express,
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });
express.partials['browser.getLocation'] =
partials['browser.getLocation'] =
'<div id="theDiv">I\'ve got a location</div>\n';

@@ -33,3 +32,3 @@ it('browser.getLocation', function() {

express.partials['browser.getLocationInView'] =
partials['browser.getLocationInView'] =
'<div id="theDiv">I\'ve got a location</div>\n';

@@ -51,3 +50,3 @@ it('browser.getLocationInView', function() {

express.partials['browser.getSize'] =
partials['browser.getSize'] =
'<div id="theDiv">I\'ve got a good size!</div>\n';

@@ -69,3 +68,3 @@ it('browser.getSize', function() {

express.partials['browser.acceptAlert'] =
partials['browser.acceptAlert'] =
'<div id="theDiv"><a>click me</a></div>\n';

@@ -87,3 +86,3 @@ it('browser.acceptAlert', function() {

express.partials['browser.dismissAlert'] =
partials['browser.dismissAlert'] =
'<div id="theDiv"><a>click me</a></div>\n';

@@ -119,3 +118,2 @@ it('browser.dismissAlert @skip-chrome', function() {

var mydir = path.join(tmp.tmpdir , 'myscreenshot');
console.log("mydir --> ", mydir);
try { fs.mkdirSync(mydir); } catch(ign) {}

@@ -129,3 +127,3 @@

try{
res = fs.readFileSync(mydir + '/abc.png', {encoding: 'base64'});
res = fs.readFileSync(mydir + '/abc.png', {encoding: 'base64'});
}catch(err){

@@ -150,3 +148,4 @@ // for 0.8

it('browser.<cookie methods>', function() {
// cookie don't seem to work in explorer
it('browser.<cookie methods> @skip-explorer', function() {
return browser

@@ -217,3 +216,3 @@ .deleteAllCookies()

express.partials['browser.active'] =
partials['browser.active'] =
'<div id="theDiv">\n' +

@@ -231,3 +230,3 @@ ' <input class="i1" type="text" value="input 1">\n' +

express.partials['browser.isVisible'] =
partials['browser.isVisible'] =
'<div id="theDiv">\n' +

@@ -249,3 +248,3 @@ ' <a href="#">a1</a>\n' +

express.partials['browser.isDisplayed'] =
partials['browser.isDisplayed'] =
'<div id="theDiv">\n' +

@@ -267,3 +266,3 @@ ' <input class="displayed" type="text" value="Hello">\n' +

express.partials['browser.isEnabled'] =
partials['browser.isEnabled'] =
'<div id="theDiv">\n' +

@@ -305,3 +304,3 @@ ' <input class="enabled" type="text" value="Hello">\n' +

it('browser.resolve', function() {
var deferred = Q.defer();
var deferred = Q.defer();
setTimeout(function() {

@@ -326,3 +325,3 @@ deferred.resolve('123');

.setHttpTimeout(env.HTTP_TIMEOUT).should.be.fulfilled;
});
});

@@ -329,0 +328,0 @@ it('err.inspect', function() {

@@ -25,8 +25,8 @@ require('../helpers/setup');

var ctx = require('./midway-base')(this),
express = ctx.express,
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var partials = {};
express.partials['asserters.nonEmptyText'] = page;
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });
partials['asserters.nonEmptyText'] = page;
it('asserters.nonEmptyText', function() {

@@ -40,3 +40,3 @@ return browser

express.partials['asserters.textInclude'] = page;
partials['asserters.textInclude'] = page;
it('asserters.textInclude', function() {

@@ -50,3 +50,3 @@ return browser

express.partials['asserters.isVisible'] = page;
partials['asserters.isVisible'] = page;
it('asserters.isVisible', function() {

@@ -59,3 +59,3 @@ return browser

express.partials['asserters.isHidden'] = page;
partials['asserters.isHidden'] = page;
it('asserters.isHidden', function() {

@@ -68,3 +68,3 @@ return browser

express.partials['asserters.jsCondition'] =
partials['asserters.jsCondition'] =
'<div id="theDiv"></div>\n';

@@ -71,0 +71,0 @@ it('asserters.jsCondition', function() {

@@ -1,2 +0,2 @@

/* global sauceJobTitle, mergeDesired */
/* global sauceJobTitle, mergeDesired, midwayUrl, Express */

@@ -20,3 +20,4 @@ require('../helpers/setup');

var browser;
var express = new Express( __dirname + '/assets' );
var partials = {};
var express;
var currentHttpConfig;

@@ -31,2 +32,3 @@

before(function() {
express = new Express( __dirname + '/assets', partials);
express.start();

@@ -38,5 +40,5 @@ });

});
afterEach(function() {
var _this = this;
var _this = this;
wd.configureHttp(currentHttpConfig);

@@ -57,3 +59,3 @@ wd.getHttpConfig().should.deep.equal(currentHttpConfig);

it("wd.configureHttp", function() {
var newConfig = {

@@ -63,3 +65,3 @@ timeout: env.HTTP_TIMEOUT || 60000,

retryDelay: env.HTTP_RETRY_DELAY || 50,
baseUrl: 'http://example.com'
baseUrl: 'http://example.com'
};

@@ -71,3 +73,3 @@

wd.configureHttp(newConfig);
wd.getHttpConfig().should.deep.equal(newConfig);

@@ -79,3 +81,3 @@ wd.configureHttp( {baseUrl: 'http://example2.com' } );

browser._httpConfig.should.deep.equal(newConfig2);
browser._httpConfig.should.deep.equal(newConfig2);

@@ -87,6 +89,6 @@ });

var wdCurrent = wd.getHttpConfig();
promiseChainRemote();
browser._httpConfig.should.deep.equal(wdCurrent);
browser._httpConfig.should.deep.equal(wdCurrent);

@@ -97,3 +99,3 @@ var newConfig = {

retryDelay: env.HTTP_RETRY_DELAY || 50,
baseUrl: 'http://example3.com'
baseUrl: 'http://example3.com'
};

@@ -104,3 +106,3 @@

browser.configureHttp(newConfig);
browser.configureHttp(newConfig);

@@ -140,3 +142,3 @@ browser._httpConfig.should.deep.equal(newConfig);

var baseUrl = matcher[1];
should.exist(baseUrl);
should.exist(baseUrl);
var relUrl = matcher[2];

@@ -158,3 +160,3 @@ should.exist(relUrl);

var baseUrl = matcher[1];
should.exist(baseUrl);
should.exist(baseUrl);
var relUrl = matcher[2];

@@ -164,3 +166,3 @@ should.exist(relUrl);

promiseChainRemote();
should.not.exist(browser._httpConfig.baseUrl);
should.not.exist(browser._httpConfig.baseUrl);
return browser

@@ -182,3 +184,3 @@ .init(buildDesired( this.runnable().parent.title + " #2"))

var baseUrl = matcher[1];
should.exist(baseUrl);
should.exist(baseUrl);
var relUrl = matcher[2];

@@ -185,0 +187,0 @@ should.exist(relUrl);

@@ -6,9 +6,8 @@ require('../helpers/setup');

describe('element ' + env.ENV_DESC, function() {
var partials = {};
var ctx = require('./midway-base')(this),
express = ctx.express,
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });
express.partials['element.text'] =
partials['element.text'] =
'<div id="theDiv">I am some text</div>';

@@ -21,3 +20,3 @@ it('element.text', function() {

express.partials['element.textPresent'] =
partials['element.textPresent'] =
'<div id="theDiv">I am some text</div>';

@@ -33,3 +32,3 @@ it('element.textPresent', function() {

express.partials['element.click'] =
partials['element.click'] =
'<div id="theDiv"><a href="#">not clicked</a></div>';

@@ -54,3 +53,3 @@ it('element.click', function() {

express.partials['element.doubleClick'] =
partials['element.doubleClick'] =
'<div id="theDiv"><a href="#">not clicked</a></div>';

@@ -75,3 +74,3 @@ it('element.doubleClick', function() {

express.partials['element.moveTo'] =
partials['element.moveTo'] =
'<div id="theDiv"><a href="#">not clicked</a></div>';

@@ -89,3 +88,3 @@ it('element.moveTo', function() {

express.partials['element.getTagName'] =
partials['element.getTagName'] =
'<div id="theDiv">\n' +

@@ -105,3 +104,3 @@ ' <input type="text">\n' +

express.partials['element.isDisplayed'] =
partials['element.isDisplayed'] =
'<div id="theDiv">\n' +

@@ -124,3 +123,3 @@ ' <input class="displayed" type="text" value="Hello">\n' +

express.partials['element.isEnabled'] =
partials['element.isEnabled'] =
'<div id="theDiv">\n' +

@@ -143,3 +142,3 @@ ' <input class="enabled" type="text" value="Hello">\n' +

express.partials['element.getComputedCss'] =
partials['element.getComputedCss'] =
'<div id="theDiv">\n' +

@@ -170,3 +169,3 @@ ' <a href="#">a1</a>\n' +

express.partials['element.getAttribute'] =
partials['element.getAttribute'] =
'<div id="theDiv" att="42">Attribute</div>\n';

@@ -180,3 +179,3 @@ it('element.getAttribute', function() {

express.partials['element.getValue'] =
partials['element.getValue'] =
'<div id="theDiv" value="qwerty">Value</div>\n';

@@ -190,3 +189,3 @@ it('element.getValue', function() {

express.partials['element.type'] =
partials['element.type'] =
'<div id="theDiv"><input></input></div>\n';

@@ -201,3 +200,3 @@ it('element.type', function() {

express.partials['element.keys'] =
partials['element.keys'] =
'<div id="theDiv"><input></input></div>\n';

@@ -212,3 +211,3 @@ it('element.keys', function() {

express.partials['element.sendKeys'] =
partials['element.sendKeys'] =
'<div id="theDiv">\n' +

@@ -238,3 +237,3 @@ ' <textarea></textarea>\n' +

express.partials['element.clear'] =
partials['element.clear'] =
'<div id="theDiv"><textarea>Not clear</textarea></div>\n';

@@ -252,3 +251,3 @@ it('element.clear', function() {

express.partials['element.elementByTagName'] =
partials['element.elementByTagName'] =
'<div id="theDiv"><a href="#">a link</a></div>\n' +

@@ -268,3 +267,3 @@ '<div id="theDiv2"><textarea></textarea></div>\n';

express.partials['element.elementsByTagName'] =
partials['element.elementsByTagName'] =
'<div id="theDiv">\n' +

@@ -287,3 +286,3 @@ ' <a href="#">a link 1</a>\n' +

express.partials['element.sleep'] =
partials['element.sleep'] =
'<div id="theDiv"></div>\n' +

@@ -300,3 +299,3 @@ it('element.sleep', function() {

express.partials['element.noop'] =
partials['element.noop'] =
'<div id="theDiv"></div>\n' +

@@ -314,3 +313,3 @@ it('element.noop', function() {

express.partials['element.chain (promise)'] =
partials['element.chain (promise)'] =
'<div id="theDiv"></div>\n' +

@@ -328,6 +327,6 @@ it('element.chain (promise)', function() {

express.partials['element.resolve'] =
partials['element.resolve'] =
'<div id="theDiv"></div>\n' +
it('element.resolve', function() {
var deferred = Q.defer();
var deferred = Q.defer();
setTimeout(function() {

@@ -334,0 +333,0 @@ deferred.resolve('123');

@@ -44,5 +44,7 @@ /* global sauceJobTitle, mergeDesired, midwayUrl, Express */

var express = new Express( __dirname + '/assets' );
var partials = {};
var express;
before(function() {
express = new Express( __dirname + '/assets', partials);
express.start();

@@ -54,7 +56,7 @@ });

});
afterEach(function() {
_(extraMethods).keys().each(function(name) {
wd.removeMethod(name);
});
wd.removeMethod(name);
});
noExtraMethodCheck();

@@ -95,3 +97,3 @@ });

express.partials['addPromisedMethod (alt promise)'] =
partials['addPromisedMethod (alt promise)'] =
'<div id="theDiv">Hello World!</div>';

@@ -102,3 +104,3 @@ it('addPromisedMethod (alt promise)', function() {

});
browser = newPromiseChainRemote();

@@ -114,3 +116,3 @@ return initAndGet(this, '#1').then(function() {

express.partials['addPromisedMethod (mixed promise)'] =
partials['addPromisedMethod (mixed promise)'] =
'<div id="theDiv">Hello World!</div>';

@@ -121,3 +123,3 @@ it('addPromisedMethod (mixed promise)', function() {

});
browser = newPromiseChainRemote();

@@ -137,3 +139,3 @@ return initAndGet(this, '#2').then(function() {

express.partials['browser.resolve (alt promise)'] =
partials['browser.resolve (alt promise)'] =
'<div id="theDiv">Hello World!</div>';

@@ -140,0 +142,0 @@ it('browser.resolve (alt promise)', function() {

require('../helpers/setup');
describe('frame ' + env.ENV_DESC + ' @skip-android @skip-ios', function() {
describe('frame ' + env.ENV_DESC, function() {
var partials = {};
var ctx = require('./midway-base')(this),
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });

@@ -10,0 +10,0 @@ it('browser.frame', function() {

require('../helpers/setup');
describe('keying ' + env.ENV_DESC, function() {
var partials = {};
var ctx = require('./midway-base')(this),
express = ctx.express,
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });

@@ -21,3 +20,3 @@ var altKey = wd.SPECIAL_KEYS.Alt;

express.partials['keying nothing'] = keyingPartial;
partials['keying nothing'] = keyingPartial;
it('keying nothing', function() {

@@ -29,3 +28,3 @@ return browser

express.partials['keying []'] = keyingPartial;
partials['keying []'] = keyingPartial;
it('keying []', function() {

@@ -37,3 +36,3 @@ return browser

express.partials['keying \'Hello\''] = keyingPartial;
partials['keying \'Hello\''] = keyingPartial;
it('keying \'Hello\'', function() {

@@ -47,3 +46,3 @@ return browser

express.partials['keying [\'Hello\']'] = keyingPartial;
partials['keying [\'Hello\']'] = keyingPartial;
it('keying [\'Hello\']', function() {

@@ -55,3 +54,3 @@ return browser

express.partials['keying [\'Hello\',\' \',\'World\',\'!\']'] = keyingPartial;
partials['keying [\'Hello\',\' \',\'World\',\'!\']'] = keyingPartial;
it('keying [\'Hello\',\' \',\'World\',\'!\']', function() {

@@ -65,3 +64,3 @@ return browser

express.partials['keying \'Hello\\n\''] = keyingPartial;
partials['keying \'Hello\\n\''] = keyingPartial;
it('keying \'Hello\\n\'', function() {

@@ -75,3 +74,3 @@ return browser

express.partials['keying \'\\r\''] = keyingPartial;
partials['keying \'\\r\''] = keyingPartial;
it('keying \'\\r\'', function() {

@@ -86,3 +85,3 @@ return browser

express.partials['keying [returnKey]'] = keyingPartial;
partials['keying [returnKey]'] = keyingPartial;
it('keying [returnKey]', function() {

@@ -96,3 +95,3 @@ return browser

express.partials['keying [enterKey]'] = keyingPartial;
partials['keying [enterKey]'] = keyingPartial;
it('keying [enterKey]', function() {

@@ -106,3 +105,3 @@ return browser

express.partials['keying [nullKey]'] = keyingPartial;
partials['keying [nullKey]'] = keyingPartial;
it('keying [nullKey]', function() {

@@ -118,3 +117,3 @@ return browser

if(!env.SAUCE) { // alt key seems to have no effect
express.partials['keying [altKey]'] = keyingPartial;
partials['keying [altKey]'] = keyingPartial;
it('keying [altKey]', function() {

@@ -121,0 +120,0 @@ return browser

/* global sauceJobTitle, mergeDesired, midwayUrl, Express */
module.exports = function(that) {
module.exports = function(that, partials) {

@@ -11,5 +11,6 @@ that.timeout(env.TIMEOUT);

var allPassed = true;
var express = new Express( __dirname + '/assets' );
var express;
before(function() {
express = new Express( __dirname + '/assets', partials );
express.start();

@@ -22,11 +23,29 @@ browser = wd.promiseChainRemote(env.REMOTE_CONFIG);

};
var desired = mergeDesired(env.DESIRED, env.SAUCE? sauceExtra : null );
return browser
.configureLogging()
.init(mergeDesired(env.DESIRED, env.SAUCE? sauceExtra : null ));
.then(function() {
return browser
.init(desired)
.catch(function() {
// trying one more time
return browser.init(desired);
});
});
});
beforeEach(function() {
return browser.get( midwayUrl(
var url = midwayUrl(
this.currentTest.parent.title,
this.currentTest.title));
this.currentTest.title
);
return browser
.get(url)
.title().should.eventually.include("WD Tests")
.catch(function() {
// trying one more time
return browser
.get(url)
.title().should.eventually.include("WD Tests");
});
});

@@ -46,6 +65,3 @@

return {
express: express,
browser: deferred.promise
};
return deferred.promise;
};
require('../helpers/setup');
describe('typing ' + env.ENV_DESC, function() {
var partials = {};
var ctx = require('./midway-base')(this),
express = ctx.express,
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });

@@ -21,3 +20,3 @@ var altKey = wd.SPECIAL_KEYS.Alt;

express.partials['typing nothing'] = typingPartial;
partials['typing nothing'] = typingPartial;
it('typing nothing', function() {

@@ -29,3 +28,3 @@ return browser

express.partials['typing []'] = typingPartial;
partials['typing []'] = typingPartial;
it('typing []', function() {

@@ -37,3 +36,3 @@ return browser

express.partials['typing \'Hello\''] = typingPartial;
partials['typing \'Hello\''] = typingPartial;
it('typing \'Hello\'', function() {

@@ -47,3 +46,3 @@ return browser

express.partials['typing [\'Hello\']'] = typingPartial;
partials['typing [\'Hello\']'] = typingPartial;
it('typing [\'Hello\']', function() {

@@ -55,3 +54,3 @@ return browser

express.partials['typing [\'Hello\',\' \',\'World\',\'!\']'] = typingPartial;
partials['typing [\'Hello\',\' \',\'World\',\'!\']'] = typingPartial;
it('typing [\'Hello\',\' \',\'World\',\'!\']', function() {

@@ -65,3 +64,3 @@ return browser

express.partials['typing \'Hello\\n\''] = typingPartial;
partials['typing \'Hello\\n\''] = typingPartial;
it('typing \'Hello\\n\'', function() {

@@ -75,3 +74,3 @@ return browser

express.partials['typing \'\\r\''] = typingPartial;
partials['typing \'\\r\''] = typingPartial;
it('typing \'\\r\'', function() {

@@ -86,3 +85,3 @@ return browser

express.partials['typing [returnKey]'] = typingPartial;
partials['typing [returnKey]'] = typingPartial;
it('typing [returnKey]', function() {

@@ -96,3 +95,3 @@ return browser

express.partials['typing [enterKey]'] = typingPartial;
partials['typing [enterKey]'] = typingPartial;
it('typing [enterKey]', function() {

@@ -106,3 +105,3 @@ return browser

express.partials['typing [nullKey]'] = typingPartial;
partials['typing [nullKey]'] = typingPartial;
it('typing [nullKey]', function() {

@@ -118,3 +117,3 @@ return browser

if(!env.SAUCE) { // alt key seems to have no effect
express.partials['typing [altKey]'] = typingPartial;
partials['typing [altKey]'] = typingPartial;
it('typing [altKey]', function() {

@@ -121,0 +120,0 @@ return browser

@@ -22,3 +22,3 @@ require('../helpers/setup');

var asserter = new Asserter(
var asserter = new Asserter(
function(browser, cb) {

@@ -67,3 +67,3 @@ browser.text(function(err, text) {

var elAsserterFalse = new Asserter(
var elAsserterFalse = new Asserter(
function(el, cb) {

@@ -74,8 +74,8 @@ cb( null, false);

var ctx = require('./midway-base')(this),
express = ctx.express,
browser;
ctx.browser.then(function(_browser) { browser = _browser; });
var partials = {};
express.partials['browser.waitFor'] = page;
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });
partials['browser.waitFor'] = page;
it('browser.waitFor', function() {

@@ -107,3 +107,3 @@ return browser

express.partials['browser.waitForElement'] = page;
partials['browser.waitForElement'] = page;
it('browser.waitForElement', function() {

@@ -126,5 +126,5 @@ return browser

.text().should.become('a waitFor child');
});
});
express.partials['browser.waitForElement - asserter'] = page;
partials['browser.waitForElement - asserter'] = page;
it('browser.waitForElement - asserter', function() {

@@ -153,5 +153,5 @@ return browser

.text().should.become('a waitFor child');
});
});
express.partials['browser.waitForElement - rejected'] = page;
partials['browser.waitForElement - rejected'] = page;
it('browser.waitForElement', function() {

@@ -180,3 +180,3 @@ return browser.chain()

express.partials['browser.waitForElementByCss'] = page;
partials['browser.waitForElementByCss'] = page;
it('browser.waitForElementByCss', function() {

@@ -183,0 +183,0 @@ return browser

require('../helpers/setup');
describe('window ' + env.ENV_DESC + ' @skip-android @skip-ios', function() {
// disabling because of random errors on sauce
describe('window ' + env.ENV_DESC + ' @skip-explorer', function() {
var browser;
beforeEach(function() {

@@ -11,5 +10,5 @@ return browser.windowHandles().should.eventually.have.length.below(2);

var ctx = require('./midway-base')(this),
express = ctx.express;
ctx.browser.then(function(_browser) { browser = _browser; });
var partials = {};
var browser;
require('./midway-base')(this, partials).then(function(_browser) { browser = _browser; });

@@ -32,3 +31,3 @@ afterEach(function() {

express.partials['browser.windowName'] = "";
partials['browser.windowName'] = "";
it('browser.windowName', function() {

@@ -40,3 +39,3 @@ return browser

express.partials['browser.windowHandle'] = "";
partials['browser.windowHandle'] = "";
it('browser.windowHandle', function() {

@@ -48,3 +47,3 @@ return browser

express.partials['browser.newWindow'] = "";
partials['browser.newWindow'] = "";
it('browser.newWindow', function() {

@@ -57,3 +56,3 @@ return browser.url(function(url) {

express.partials['browser.window'] = "";
partials['browser.window'] = "";
it('browser.window', function() {

@@ -75,3 +74,3 @@ return Q.all([

express.partials['browser.windowHandles'] = "";
partials['browser.windowHandles'] = "";
it('browser.windowHandles', function() {

@@ -90,3 +89,3 @@ return browser

express.partials['browser.getWindowSize'] = "";
partials['browser.getWindowSize'] = "";
it('browser.getWindowSize', function() {

@@ -107,3 +106,3 @@ return browser

express.partials['browser.setWindowSize'] = "";
partials['browser.setWindowSize'] = "";
it('browser.setWindowSize', function() {

@@ -129,3 +128,3 @@ return browser

express.partials['browser.getWindowPosition'] = "";
partials['browser.getWindowPosition'] = "";
it('browser.getWindowPosition', function() {

@@ -146,3 +145,3 @@ return browser

express.partials['browser.setWindowPosition'] = "";
partials['browser.setWindowPosition'] = "";
it('browser.setWindowPosition', function() {

@@ -149,0 +148,0 @@ return browser

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc