IOS UI Testing: how to dismiss a series of system alerts( microphone access ) via code using fastlane snapshot

358 Views Asked by At

I use mac mojave 10.14.3 and react-native version - 0.59.1, fastlane latest version. I tried to run the fastlane screenshot via ios xcuitest But I couldn't dismiss the system alert. I have attached my code and alert screen

Could you please help me

addUIInterruptionMonitor(withDescription: "System Dialog") {
        (alert) -> Bool in
        let okButton = alert.buttons["OK"]
        if okButton.exists {
          okButton.tap()
        }

        let allowButton = alert.buttons["Allow"]
        if allowButton.exists {
          allowButton.tap()
        }

        return true
      }

      app.tap()
      snapshot("04EndRecord")

this is my alert and app. this alert shows outside of the app, then how can i handle that?

Microphone access alert

2

There are 2 best solutions below

2
cesarmarch On

Are the system alerts automatically triggered or after a user interaction ? You should add your InterruptionMonitor before the dialogs are triggered.

0
cesarmarch On

I faced this issue a few months ago. It appeared when I wanted to use sounds in the app. I disabled sounds during running UI tests.

Can you apply the same process to your app ?