mirror of
https://github.com/appium/appium.git
synced 2026-01-27 20:59:06 -06:00
make sure implicit wait works after ios reset (fix #437)
This commit is contained in:
@@ -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});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user