Fixed sleep function to use setTimeout instead of setFindTimeout on something that doesn't exist.

This commit is contained in:
LeeDr 2015-10-27 18:37:13 -05:00 committed by Joe Fleming
parent 25c78e6a0d
commit fb5fcca5b6

View file

@ -6,10 +6,6 @@ define(function (require) {
var Promise = require('bluebird');
var moment = require('moment');
// the page object is created as a constructor
// so we can provide the remote Command object
// at runtime
function Common(remote) {
this.remote = remote;
}
@ -19,7 +15,6 @@ define(function (require) {
Common.prototype = {
constructor: Common,
tryForTime: function tryForTime(timeout, block) {
var self = this;
var start = Date.now();
@ -48,26 +43,22 @@ define(function (require) {
return Promise.try(attempt);
},
log: function log(logString) {
console.log(moment().format('HH:mm:ss.SSS') + ': ' + logString);
},
sleep: function sleep(sleepMilliseconds) {
var self = this;
self.log('... sleep(' + sleepMilliseconds + ') start');
return this.remote
.setFindTimeout(sleepMilliseconds)
.findByCssSelector('youWillNeverFindThis')
.catch(function (reason) {
var promise = new Promise(function (resolve, reject) {
setTimeout(function () {
self.log('... sleep(' + sleepMilliseconds + ') end');
});
resolve({});
}, sleepMilliseconds);
});
return promise;
}
// …additional page interaction tasks…
};
return Common;