UITests: cannot disable precise location on iOS 14.5

Viewed 113

I have a UITest (implemented using XCTest) in which I want to test my app’s behaviour when user want to disable precise location (a new feature introduced in iOS 14).

When location authorization system alert appears (check attached screenshot), I can access it with the following code

let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let locationAlert = springboard.alerts.element

And I can access the precise location button with:

locationAlert.buttons["Esatta: sì"]

However, when interacting with it, the alert is considered as a "blocking" element and the default "interruption monitor" is invoked, resulting in the alert to be dismissed

t =   834.87s         Check for interrupting elements affecting "Esatta: sì" Button
    t =   834.92s         Found 1 interrupting element:
    t =   834.92s             Find the "Vuoi consentire a “*****” di utilizzare la tua posizione?" Alert
    t =   834.97s             "Vuoi consentire a “*****” di utilizzare la tua posizione?" Alert from Application 'com.apple.springboard'
    t =   834.97s         Invoking UI interruption monitors for "Vuoi consentire a “*****” di utilizzare la tua posizione?" Alert from Application 'com.apple.springboard'
    t =   834.97s             Find the "Vuoi consentire a “*****” di utilizzare la tua posizione?" Alert
    t =   835.01s             Checking existence of `Button`
    t =   835.06s             Get all elements bound by accessibility element for: Elements matching predicate 'userTestingAttributes CONTAINS "default-button"'
    t =   835.14s             Checking existence of `"Non consentire" Button`
    t =   835.19s             Default interruption handler attempting to dismiss alert by tapping "Non consentire" Button.
    t =   835.19s             Tap "Non consentire" Button
    t =   835.19s                 Wait for com.apple.springboard to idle
    t =   835.22s                 Find the "Non consentire" Button
    t =   835.28s                 Check for interrupting elements affecting "Non consentire" Button
    t =   835.33s                 Synthesize event
    t =   835.42s                 Wait for com.apple.springboard to idle
    t =   835.84s             Verifying handling...
    t =   835.84s                 Check for interrupting elements affecting "Esatta: sì" Button
    t =   835.85s                     Wait for xxxxxx to idle
    t =   835.91s             Confirmed successful handling of interrupting element

This only occurs when using Xcode 12.5, I don't have any problem with previous versions.

enter image description here

0 Answers
Related