Search code examples
iosrubycucumberappiumappium-ios

Automatically dismiss iOS Alerts when automating an app with Appium


I am using Ruby in a Cucumber automation framework to automate my Android and iOS application. I am using Appium 1.6.4 beta as it supports iOS 10.2.

When the Appium server first installs the iOS app on the device it is prompted with an Alert Dialog asking if I want to allow notifications. With Appium as far as I can tell the "autoAcceptAlerts" capability does not currently work.

My main question is how would I go about checking if the alert dialog is there and then use something like find_element to press the "Allow" button but not have to edit my feature files. Is there a way I can use my "Log in as an Existing User" step to check for the alert and dismiss it if it's there and if not just continue with the login flow?

I tried to use find_element(xpath to OK button).exists? to make an if/else statement but I think I'm just doing it wrong. If the alert is not present the step fails and my test run stops.

I'm sorry if this question was answered somewhere on her but I've been unable to find a good answer for this question myself. Thank you for any help you can provide.


Solution

  • According to documentation from the Appium team it appears as though the desired capability for automatically accepting all dialogs is broken. As such I have hard-coded the action rather than relying on appium. Perhaps this will be fixed in the next version.