mirror of
https://github.com/appium/appium.git
synced 2026-04-26 05:18:53 -05:00
automatically accept photo permission alerts (fix #1700)
and add manualPermissionAlerts desired cap if you want to handle things manually
This commit is contained in:
@@ -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|
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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") {
|
||||
|
||||
Vendored
+4
-1
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user