mirror of
https://github.com/appium/appium.git
synced 2026-05-23 04:18:53 -05:00
add a pre-launch mode that doesn't listen until sim is running
This commit is contained in:
@@ -39,6 +39,21 @@ 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");
|
||||
process.exit();
|
||||
} else {
|
||||
var me = this;
|
||||
this.start({}, function(err, device) {
|
||||
me.stop(function(err, res) {
|
||||
cb(me);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Appium.prototype.start = function(desiredCaps, cb) {
|
||||
this.origApp = this.args.app;
|
||||
this.configure(desiredCaps, _.bind(function(err) {
|
||||
|
||||
@@ -32,5 +32,9 @@ module.exports = function() {
|
||||
, { defaultValue: true, required: false, help: 'remove Instruments trace directories'
|
||||
});
|
||||
|
||||
parser.addArgument([ '-l', '--launch' ]
|
||||
, { defaultValue: false, required: false, help: 'pre-launch the ios-sim'
|
||||
});
|
||||
|
||||
return parser;
|
||||
};
|
||||
|
||||
@@ -48,13 +48,21 @@ var main = function(args, readyCb, doneCb) {
|
||||
// Hook up REST http interface
|
||||
appiumServer.attachTo(rest);
|
||||
// Start the web server that receives all the commands
|
||||
server.listen(args.port, args.address, function() {
|
||||
var logMessage = "Appium REST http interface listener started on "+args.address+":"+args.port;
|
||||
logger.info(logMessage.cyan);
|
||||
var next = function(appiumServer) {
|
||||
server.listen(args.port, args.address, function() {
|
||||
var logMessage = "Appium REST http interface listener started on "+args.address+":"+args.port;
|
||||
logger.info(logMessage.cyan);
|
||||
});
|
||||
if (readyCb) {
|
||||
readyCb(appiumServer);
|
||||
}
|
||||
});
|
||||
};
|
||||
if (args.launch) {
|
||||
logger.info("Starting Appium in pre-launch mode".cyan);
|
||||
appiumServer.preLaunch(next);
|
||||
} else {
|
||||
next(appiumServer);
|
||||
}
|
||||
server.on('close', doneCb);
|
||||
return server;
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@ describe("appiumutils", function() {
|
||||
app: path.resolve(__dirname, "../../../sample-code/apps/UICatalog/build/Release-iphonesimulator/UICatalog.app")
|
||||
, verbose: false
|
||||
, udid: null
|
||||
, launch: true
|
||||
, port: 4723
|
||||
, address: '127.0.0.1'
|
||||
, remove: true }
|
||||
|
||||
Reference in New Issue
Block a user