Q8 of 26 · Mobile QA

How do you handle system permission dialogs and interrupts like calls and notifications in automated tests?

Mobile QAMidmobileappiumpermissionsinterruptsnotificationsalerts

Short answer

Short answer: Pre-grant permissions via Appium capabilities before the session starts — this prevents the dialog from appearing at all. For run-time interrupts (calls, notifications), use Appium's autoAcceptAlerts (iOS) capability or platform-specific driver commands to dismiss or accept the system dialog programmatically.

Detail

Permission dialogs are the most common source of test failures on first install. The right approach is to prevent them rather than handle them after the fact:

  • Android (UIAutomator2): set appium:permissions capability to a JSON object of permission → allow before the session starts. UIAutomator2 grants them during install, before the app ever requests them.
  • iOS (XCUITest): use the appium:defaultAlertAction capability set to accept, or handle individual alerts with the mobile: alert execute script command.

Run-time interrupts (incoming calls, notification banners, system dialogs like low battery) can arrive at any point. Strategies:

  • Enable autoAcceptAlerts: true (iOS) to auto-dismiss any system alert. Useful in CI but dangerous if alerts carry important information.
  • Use conditional waits: check for the system alert element before interacting with app elements, dismiss it explicitly, then proceed.
  • Real-device pipelines: configure the device profile to suppress notifications during test runs (Do Not Disturb mode via ADB on Android, Focus mode via MDM on iOS).

// EXAMPLE

android-permissions.json

{
  "platformName": "Android",
  "appium:automationName": "UIAutomator2",
  "appium:app": "./MyApp.apk",
  "appium:permissions": {
    "com.example.myapp": {
      "android.permission.CAMERA": "allow",
      "android.permission.ACCESS_FINE_LOCATION": "allow"
    }
  }
}

// WHAT INTERVIEWERS LOOK FOR

Distinguishes pre-grant (capability-based, preferred) from run-time handling. Knows the platform difference between Android permissions capability and iOS autoAcceptAlerts.

// COMMON PITFALL

Using autoAcceptAlerts: true as the blanket solution. It dismisses every alert including destructive ones — a dialog asking to delete data will be silently accepted, potentially corrupting test state.