Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing an SFAuthenticationSession alert in an XCUITest with addUIInterruptionMonitor()

Has anybody successfully used addUIInterruptionMonitor to clear the alert produced by start()ing an SFAuthenticationSession while running an XCUITest?

I can't get it to work on Xcode 9.1/iOS 11.1.1 (simulator or device). The standard advice (setting up the handler and subsequently interacting with the device before the alert appears) does not help.

The test recorder says app.alerts.firstMatch.buttons["Continue"]).tap() should do the trick, but that doesn't work either. This technique from another SO answer works sometimes, but not consistently on CI.

So I'd like to know if the "official" solution has ever worked for anyone.

like image 809
Robert Atkins Avatar asked Nov 17 '17 13:11

Robert Atkins


1 Answers

I couldn't get this to work:

let continueButton = app.alerts.buttons["Continue"]
XCTAssert(waitAndTap(continueButton), "could not tap on alert \"Continue\" button"

But this hack seems to do the trick:

let statusBarsQuery = app.statusBars
statusBarsQuery.element.tap()
like image 186
tanya Avatar answered Sep 28 '22 07:09

tanya