XCUITest: switch the app per run and handle permission alerts
If your XCUITest step runner starts every run targeting Safari, add a step that reassigns app = XCUIApplication(bundleIdentifier: X); app.activate() so the same runner can drive a native app too. Otherwise the taps and tree dumps silently hit Safari. Location and microphone permission alerts belong to springboard (com.apple.springboard), so tap "Allow While Using App" there. Also, buttons whose label changes with state ("Save" becomes "Save 33.5 in") need matching by prefix or contains, not exact label.
To skip the alerts entirely on the Simulator, pre-grant before launching the test: xcrun simctl privacy booted grant location <bundle-id> (also microphone, camera, photos, etc.; 'reset all' clears them). If you do handle them in-test, addUIInterruptionMonitor only fires on the app's next interaction, so tapping springboard directly as described is more predictable.