support pre-launching safari

This commit is contained in:
Jonathan Lipps
2013-03-07 17:09:00 -08:00
parent 8ac8a161df
commit d9db9834a6
2 changed files with 21 additions and 11 deletions
+14 -10
View File
@@ -64,19 +64,23 @@ Appium.prototype.attachTo = function(rest, cb) {
Appium.prototype.preLaunch = function(cb) {
logger.info("Pre-launching app");
if (!this.args.app) {
logger.error("Cannot pre-launch app if it isn't passed in via --app");
if (!this.args.app && !this.args.safari) {
logger.error("Cannot pre-launch app if it isn't passed in via --app or --safari");
process.exit();
} else {
var me = this;
var caps = {};
this.start(caps, function(err, device) {
// since we're prelaunching, it might be a while before the first
// command comes in, so let's not have instruments quit on us
device.setCommandTimeout(600, function() {
me.preLaunched = true;
cb(me);
});
if (err) {
cb(err, null);
} else {
// since we're prelaunching, it might be a while before the first
// command comes in, so let's not have instruments quit on us
device.setCommandTimeout(600, function() {
me.preLaunched = true;
cb(null, me);
});
}
});
}
};
@@ -198,11 +202,11 @@ Appium.prototype.configure = function(desiredCaps, cb) {
logger.warn("Sticking with default app: " + this.args.app);
cb(null);
}
} else if (this.args.safari === true) {
this.configureSafari(desiredCaps, cb);
} else if (!this.args.app) {
cb("No app set; either start appium with --app or pass in an 'app' " +
"value in desired capabilities");
} else if (this.args.safari === true) {
this.configureSafari(desiredCaps, cb);
} else {
logger.info("Using app from command line: " + this.args.app);
cb(null);
+7 -1
View File
@@ -85,7 +85,13 @@ var main = function(args, readyCb, doneCb) {
};
if (args.launch) {
logger.info("Starting Appium in pre-launch mode".cyan);
appiumServer.preLaunch(next);
appiumServer.preLaunch(function(err, appiumServer) {
if (err) {
logger.error("Could not pre-launch appium: " + err);
} else {
next(appiumServer);
}
});
} else {
next(appiumServer);
}