mirror of
https://github.com/appium/appium.git
synced 2026-02-14 05:50:00 -06:00
fall back to adb.startApp if selendroid's instrumentation doesn't launch it in 1.8s
This commit is contained in:
@@ -1284,10 +1284,10 @@ ADB.prototype.waitForNotActivity = function(cb) {
|
||||
getFocusedApp();
|
||||
};
|
||||
|
||||
ADB.prototype.waitForActivity = function(cb) {
|
||||
ADB.prototype.waitForActivity = function(cb, waitMsOverride) {
|
||||
this.requireApp();
|
||||
logger.info("Waiting for app's activity to become focused");
|
||||
var waitMs = 20000
|
||||
var waitMs = waitMsOverride || 20000
|
||||
, intMs = 750
|
||||
, endAt = Date.now() + waitMs
|
||||
, targetActivity = this.appWaitActivity || this.appActivity;
|
||||
|
||||
@@ -100,19 +100,29 @@ Selendroid.prototype.waitForServer = function(cb) {
|
||||
Selendroid.prototype.createSession = function(cb) {
|
||||
logger.info("Creating Selendroid session");
|
||||
var data = {desiredCapabilities: this.desiredCaps};
|
||||
this.proxyTo('/wd/hub/session', 'POST', data, _.bind(function(err, res, body) {
|
||||
this.proxyTo('/wd/hub/session', 'POST', data, function(err, res, body) {
|
||||
if (err) return cb(err);
|
||||
|
||||
if (res.statusCode === 301 && body.sessionId) {
|
||||
logger.info("Successfully started selendroid session");
|
||||
this.selendroidSessionId = body.sessionId;
|
||||
cb(null, body.sessionId);
|
||||
this.adb.waitForActivity(function(err) {
|
||||
if (err) {
|
||||
logger.info("Selendroid hasn't started app yet, let's do it " +
|
||||
"manually with adb.startApp");
|
||||
return this.adb.startApp(function(err) {
|
||||
if (err) return cb(err);
|
||||
return cb(null, body.sessionId);
|
||||
}.bind(this));
|
||||
}
|
||||
return cb(null, body.sessionId);
|
||||
}.bind(this), 1800);
|
||||
} else {
|
||||
logger.error("Selendroid create session did not work. Status was " +
|
||||
res.statusCode + " and body was " + body);
|
||||
cb(new Error("Did not get session redirect from selendroid"));
|
||||
}
|
||||
}, this));
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
Selendroid.prototype.deleteSession = function(cb) {
|
||||
|
||||
Reference in New Issue
Block a user