[appium][xcuitest] interact with alerts with appium-xcuitest-driver v6.0.0+

[Update] https://github.com/appium/appium-xcuitest-driver/blob/master/docs/guides/troubleshooting.md#interact-with-dialogs-managed-by-comapplespringboard guides about this behavior. For example defaultActiveApplication via Settings API is also a new method to take care the handling.

[update] The change was reverted in 5.15.1 to avoid possible confusion. The fix and change as the side effect is in 6.0.0.

As of 5.14.1, it fixed an active application selection https://github.com/appium/appium/issues/19716#issuecomment-1911895659, but as a side effect, I noticed selecting system dialogs (which is com.apple.springboard‘s elements) may fail. As workarounds, the methods below would help to avoid the behavior.

Change the settings to select an alert item

driver.settings.update({acceptAlertButtonSelector: '**/XCUIElementTypeButton[`label=="Allow Once"`]'})
driver.switch_to.alert.accept

mobile: alert

driver.execute_script 'mobile: alert', {action: 'accept', buttonLabel: 'Allow Once'}

Activate the spring board

driver.activate_app 'com.apple.springboard'

Then, the page source prints the alet elements as well.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.