make sure implicit wait works after ios reset (fix #437)

This commit is contained in:
Jonathan Lipps
2013-04-15 12:26:57 -07:00
parent 0eacda563a
commit 0d4eae8cd3
2 changed files with 28 additions and 17 deletions

View File

@@ -443,11 +443,13 @@ Appium.prototype.reset = function(cb) {
logger.info("Resetting app mid-session");
if (this.isIos() || !this.fastReset) {
var me = this
, oldImpWait = this.device.implicitWaitMs
, oldId = this.sessionId;
this.stop(function() {
logger.info("Restarting app");
me.start(me.desiredCapabilities, function() {
me.device.implicitWaitMs = oldImpWait;
me.sessionId = oldId;
cb(null, {status: status.codes.Success.code, value: null});
});

View File

@@ -24,29 +24,38 @@ describeWd('command timeout', function(h) {
});
describeWd('check implicit wait', function(h) {
var impWaitSecs = 4;
var impWaitCheck = function(cb) {
var before = new Date().getTime() / 1000;
h.driver.elementsByTagName('notgonnabethere', function(err, missing) {
var after = new Date().getTime() / 1000;
should.ok(after - before < (impWaitSecs + 2));
should.ok(after - before > impWaitSecs);
missing.length.should.equal(0);
cb();
});
};
it('should set the implicit wait for finding elements', function(done) {
h.driver.setImplicitWaitTimeout(10 * 1000, function(err) {
h.driver.setImplicitWaitTimeout(impWaitSecs * 1000, function(err) {
should.not.exist(err);
var before = new Date().getTime() / 1000;
h.driver.elementsByTagName('notgonnabethere', function(err, missing) {
var after = new Date().getTime() / 1000;
should.ok(after - before < 12);
should.ok(after - before > 10);
missing.length.should.equal(0);
done();
});
impWaitCheck(done);
});
});
it('should set the implicit wait for finding element', function(done) {
h.driver.setImplicitWaitTimeout(10 * 1000, function(err) {
h.driver.setImplicitWaitTimeout(impWaitSecs * 1000, function(err) {
should.not.exist(err);
var before = new Date().getTime() / 1000;
h.driver.elementByTagName('notgonnabethere', function(err) {
var after = new Date().getTime() / 1000;
should.ok(after - before < 12);
should.ok(after - before > 10);
should.exist(err);
done();
impWaitCheck(done);
});
});
it('should work even with a reset in the middle', function(done) {
h.driver.setImplicitWaitTimeout(impWaitSecs * 1000, function(err) {
should.not.exist(err);
impWaitCheck(function() {
h.driver.execute("mobile: reset", function(err) {
should.not.exist(err);
impWaitCheck(done);
});
});
});
});