6

I'm currently using

addUIInterruptionMonitor(withDescription: "System alerts") { alert in
      let notNowButton = alert.buttons["Not Now"]
      if notNowButton.exists {
         notNowButton.tap()
         return true
      }
      return false
 }

to dismiss system alerts disaplayed during the execution of ui test but the following "sheet" is not recognized as an alert and I cannot dismiss it.

enter image description here

I have used the "record" button in xcode to get the ui coordinate of the "Not now" button:

app.scrollViews.otherElements.buttons["Not now"].tap() 

I face this problem related to the above sheet with Xcode 14.3. Is there a solution to dismiss these systema "sheets" during the execution?

Jon Reid
  • 20,545
  • 2
  • 64
  • 95
chiarotto.alessandro
  • 1,491
  • 1
  • 13
  • 31
  • Also having this issue. This should be automatically dismissed by the system or Apple should give us a way to turn this off for tests easily. – Adam Sousa Jun 16 '23 at 22:08

2 Answers2

4

By the way we solved this problem using the following method:

private func eventuallyDismissPasswordAlert(_ app: XCUIApplication) {
   if app.scrollViews.otherElements.buttons["Non ora"].waitForExistence(timeout: 2) {
       tap(app.scrollViews.otherElements.buttons["Non ora"])
       return
   }
   if app.scrollViews.otherElements.buttons["Not Now"].waitForExistence(timeout: 2) {
       tap(app.scrollViews.otherElements.buttons["Not Now"])
       return
   }
}
chiarotto.alessandro
  • 1,491
  • 1
  • 13
  • 31
1

Assuming you're on simulator or on a device that doesn't need the feature, you can go to the Settings app and disable filling passwords from the keychain under Passwords and Password Options. That will keep the sheet from ever popping.

enter image description here

Mark Thormann
  • 2,522
  • 1
  • 21
  • 23
  • 2
    Thanks, sorry if I have not mentioned this solution, but I would like to avoid this solution because is time/credit consuming since we have more then 900 ui test running on continuos integrations. I should set "Autofill pwd" to false for each UI test. – chiarotto.alessandro Apr 11 '23 at 13:15