automatically accept photo permission alerts (fix #1700)

and add manualPermissionAlerts desired cap if you want to
handle things manually
This commit is contained in:
Jonathan Lipps
2014-01-07 14:40:26 -08:00
parent 44fc930cb8
commit 9fb163be2e
4 changed files with 17 additions and 1 deletions
+1
View File
@@ -33,3 +33,4 @@ Appium server capabilities
|`language`| Language to set for the iOS Simulator|e.g. `fr`|
|`launchTimeout`| Amount of time in ms to wait for instruments before assuming it hung and failing the session|e.g. `20000`|
|`locale`| Locale to set for the iOS Simulator|e.g. `fr_CA`|
|`manualPermissionAlerts`| Handle iOS permissions alerts (e.g., for photos) on your own. Otherwise, Appium will automatically accept them for you|
+1
View File
@@ -520,6 +520,7 @@ Appium.prototype.initDevice = function() {
, logNoColors: this.args.logNoColors
, flakeyRetries: this.args.backendRetries
, origAppPath: this.origAppPath
, manualPermissionAlerts: this.desiredCapabilities.manualPermissionAlerts
};
if (this.desiredCapabilities.safari || this.desiredCapabilities.iwebview) {
this.device = new Safari(iosOpts);
+11
View File
@@ -53,6 +53,7 @@ IOS.prototype.init = function(args) {
this.autoWebview = args.autoWebview;
this.withoutDelay = args.withoutDelay;
this.useDefaultDevice = args.defaultDevice;
this.manualPermissionAlerts = !!args.manualPermissionAlerts;
this.xcodeFolder = null;
this.xcodeVersion = null;
this.iOSSDKVersion = null;
@@ -198,6 +199,7 @@ IOS.prototype.start = function(cb, onDie) {
this.startInstruments.bind(this),
this.onInstrumentsLaunch.bind(this),
this.setBundleId.bind(this),
this.setBootstrapConfig.bind(this),
this.setInitialOrientation.bind(this),
], function(err) {
cb(err);
@@ -292,6 +294,15 @@ IOS.prototype.setInitialOrientation = function(cb) {
}
};
IOS.prototype.setBootstrapConfig = function(cb) {
logger.info("Setting bootstrap config keys/values");
var pre = "setBootstrapConfig: ";
var cmd = pre + "manualPermissionAlerts=" + JSON.stringify(this.manualPermissionAlerts);
this.proxy(cmd, function(err) {
cb(err); // discard res
});
};
IOS.prototype.onUnexpectedInstrumentsExit = function(code, traceDir) {
logger.info("Instruments exited unexpectedly");
if (typeof this.cbForCurrentCmd === "function") {
+4 -1
View File
@@ -17,7 +17,10 @@ var bootstrapSettings = {};
UIATarget.onAlert = function(alert) {
if (alert.name() && alert.name().indexOf("attempting to open a pop-up") !== -1) {
alert.defaultButton().tap();
return true;
} else if (!bootstrapSettings.manualPermissionAlerts) {
if (alert.name().indexOf("Would Like to Access Your Photos") !== -1) {
alert.defaultButton().tap();
}
}
return true;
};