autoAcceptAlerts not working on Appium 1.6 running on iOS 10 simulator

As you can see in the logs “autoAcceptAlerts” is set to “true” but native iOS alerts aren’t automatically dismissed as they were with the previous Appium version before XCUITest


2016-10-31 10:09:29:456 - info: [Appium] Creating new XCUITestDriver session
2016-10-31 10:09:29:457 - info: [Appium] Capabilities:
2016-10-31 10:09:29:471 - info: [Appium] automationName: ‘XCUITest’
2016-10-31 10:09:29:471 - info: [Appium] platformName: ‘iOS’
2016-10-31 10:09:29:471 - info: [Appium] platformVersion: ‘10.0’
2016-10-31 10:09:29:471 - info: [Appium] deviceName: ‘iPhone 6’
2016-10-31 10:09:29:471 - info: [Appium] app: ‘/Users/guy.tsype/Desktop/Workspaces/’
2016-10-31 10:09:29:472 - info: [Appium] newCommandTimeout: 25
2016-10-31 10:09:29:472 - info: [Appium] language: ‘en’
2016-10-31 10:09:29:472 - info: [Appium] autoAcceptAlerts: true
2016-10-31 10:09:29:475 - info: [debug] [XCUITest] XCUITestDriver version: 2.0.26
2016-10-31 10:09:29:482 - info: [BaseDriver] Session created with session id: 0f18edd0-6f69-4505-978e-3d878aa81cf2
2016-10-31 10:09:29:523 - info: [debug] [XCUITest] Xcode version set to ‘8.0’
2016-10-31 10:09:29:529 - info: [debug] [XCUITest] iOS SDK Version set to ‘10.0’
2016-10-31 10:09:29:648 - info: [iOSSim] Constructing iOS simulator for Xcode version 8.0 with udid ‘C7DDD898-51E8-48CF-BAB4-4B1AA366FB32’
2016-10-31 10:09:29:650 - info: [XCUITest] Determining device to run tests on: udid: ‘C7DDD898-51E8-48CF-BAB4-4B1AA366FB32’, real device: false
2016-10-31 10:09:29:651 - info: [BaseDriver] Using local app ‘/Users/guy.tsype/Desktop/Workspaces/’
2016-10-31 10:09:29:652 - info: [debug] [XCUITest] Checking whether app is actually present
2016-10-31 10:09:29:653 - info: [debug] [ios-app-utils] Getting bundle ID from app
2016-10-31 10:09:29:717 - info: [debug] [iOSLog] Starting iOS 10.0 simulator log capture
2016-10-31 10:09:29:717 - info: [debug] [iOSLog] System log path: /Users/guy.tsype/Library/Logs/CoreSimulator/C7DDD898-51E8-48CF-BAB4-4B1AA366FB32/system.log
2016-10-31 10:09:29:734 - info: [XCUITest] Setting up simulator
2016-10-31 10:09:29:737 - info: [debug] [iOS] Setting locale information
2016-10-31 10:09:29:738 - info: [debug] [iOSSim] New language: en
2016-10-31 10:09:29:738 - info: [debug] [iOSSim] No locale updates necessary.
2016-10-31 10:09:29:739 - info: [debug] [iOS] No iOS / app preferences to set

1 Like

I have the same problem and am looking around for solution. I remember stumbling on a post that had some work around by disabling it “manually” trough the driver or something.

You can use driver.switchTo().alert().accept();

Yes. Thank you. I did try the python version but it seems I had used a wrong syntax or sth. Now that you suggested it I decided to try it again and it did work.

I’m able to manually accept alerts as a UI step, but I prefer to have a default configuration that takes care of all alerts when they come up. Is that possible? Does driver.switchTo().alert().accept(); apply to this?

I just noticed that the rest of the test doesn’t pass. Driver can’t find the elements that it normally does. I believe it is due to the switch_to. How do I switch back to the app after the alert is accepted.

Edit: I used sleep() after accepting and it worked

capabilities.setCapability(“waitForAppScript”,"$.delay(3000); $.acceptAlert();$.delay(1000); $.acceptAlert();");

To This:
IOSDriver iosdriver = new IOSDriver(new URL(“”+strAppiumPort+"/wd/hub"), capabilities);
try {Thread.sleep(2000);}catch (Exception e) {}
try {Thread.sleep(2000);}catch (Exception e) {}

@dduphorn it does not work with Appium v1.6.4-beta

I tried with alert.accept(); as well.
But it does not respond.

Alert is for notifications allow and looks like this.