mirror of
https://github.com/appium/appium.git
synced 2026-02-14 05:50:00 -06:00
Added solution which allows you to run tests against safari without 20-30 seconds time out using appium.
This commit is contained in:
@@ -628,9 +628,14 @@ Appium.prototype.stop = function(cb) {
|
||||
}
|
||||
|
||||
logger.info('Shutting down appium session...');
|
||||
this.device.stop(function(code) {
|
||||
this.onDeviceDie(code, cb);
|
||||
}.bind(this));
|
||||
if (typeof this.device.isSafariLauncherApp !== "undefined" && this.device.isSafariLauncherApp === true) {
|
||||
this.device.stopRemote();
|
||||
this.onDeviceDie(0, cb);
|
||||
} else {
|
||||
this.device.stop(function(code) {
|
||||
this.onDeviceDie(code, cb);
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ var IOS = function(args) {
|
||||
this.onPageChangeCb = null;
|
||||
this.useRobot = args.robotPort > 0;
|
||||
this.robotUrl = this.useRobot ? "http://" + args.robotAddress + ":" + args.robotPort + "" : null;
|
||||
this.safariLauncherAppName = "/safarilauncher.app";
|
||||
this.isSafariLauncherApp = (typeof args.app !== "undefined") && (args.app.toLowerCase().indexOf(this.safariLauncherAppName, args.app.length - this.safariLauncherAppName.length) !== -1);
|
||||
this.capabilities = {
|
||||
version: '6.0'
|
||||
, webStorageEnabled: false
|
||||
@@ -177,6 +179,7 @@ IOS.prototype.start = function(cb, onDie) {
|
||||
this.instruments = instruments(
|
||||
this.app || this.bundleId
|
||||
, this.udid
|
||||
, this.isSafariLauncherApp
|
||||
, path.resolve(__dirname, 'uiauto/bootstrap.js')
|
||||
, this.automationTraceTemplatePath
|
||||
, sock
|
||||
@@ -572,7 +575,7 @@ IOS.prototype.cleanupAppState = function(cb) {
|
||||
|
||||
IOS.prototype.listWebFrames = function(cb, exitCb) {
|
||||
var isDone = false;
|
||||
if (!this.bundleId) {
|
||||
if (!this.bundleId && !this.isSafariLauncherApp) {
|
||||
logger.error("Can't enter web frame without a bundle ID");
|
||||
return cb(new Error("Tried to enter web frame without a bundle ID"));
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ var spawn = require('child_process').spawn
|
||||
, mkdirp = require('mkdirp')
|
||||
, codes = require('../app/uiauto/lib/status.js').codes;
|
||||
|
||||
var Instruments = function(app, udid, bootstrap, template, sock, withoutDelay, xcodeVersion, webSocket, cb, exitCb) {
|
||||
var Instruments = function(app, udid, isSafariLauncherApp, bootstrap, template, sock, withoutDelay, xcodeVersion, webSocket, cb, exitCb) {
|
||||
this.app = app;
|
||||
this.udid = udid;
|
||||
this.isSafariLauncherApp = isSafariLauncherApp;
|
||||
this.bootstrap = bootstrap;
|
||||
this.template = template;
|
||||
this.withoutDelay = withoutDelay;
|
||||
@@ -69,7 +70,13 @@ Instruments.prototype.startSocketServer = function(sock) {
|
||||
this.exitHandler(1);
|
||||
};
|
||||
|
||||
var socketConnectTimeout = setTimeout(onSocketNeverConnect.bind(this), 90000);
|
||||
// for safari launcher app we simply let the socket timeout and catch it.
|
||||
var socketConnectTimeout = null;
|
||||
if (this.isSafariLauncherApp) {
|
||||
socketConnectTimeout = setTimeout(onSocketNeverConnect.bind(this), 8000);
|
||||
} else {
|
||||
socketConnectTimeout = setTimeout(onSocketNeverConnect.bind(this), 90000);
|
||||
}
|
||||
|
||||
this.socketServer = net.createServer({allowHalfOpen: true}, function(conn) {
|
||||
if (!this.hasConnected) {
|
||||
@@ -160,6 +167,9 @@ Instruments.prototype.launch = function() {
|
||||
|
||||
self.proc.on('exit', function(code) {
|
||||
self.debug("Instruments exited with code " + code);
|
||||
if (self.isSafariLauncherApp){
|
||||
self.readyHandler();
|
||||
}
|
||||
if (self.curCommand && self.curCommand.cb) {
|
||||
self.curCommand.cb({
|
||||
status: code,
|
||||
@@ -355,7 +365,7 @@ Instruments.prototype.debug = function(msg) {
|
||||
|
||||
/* NODE EXPORTS */
|
||||
|
||||
module.exports = function(server, app, udid, bootstrap, template, sock, withoutDelay, webSocket, cb, exitCb) {
|
||||
return new Instruments(server, app, udid, bootstrap, template, sock, withoutDelay, webSocket, cb, exitCb);
|
||||
module.exports = function(server, app, isSafariLauncherApp, udid, bootstrap, template, sock, withoutDelay, webSocket, cb, exitCb) {
|
||||
return new Instruments(server, app, isSafariLauncherApp, udid, bootstrap, template, sock, withoutDelay, webSocket, cb, exitCb);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user