swiftautomationios-ui-automationxcuitest

How to access Apple Id "Sign In" dialog from UI Test


I have one UI tests and want to test that I press "close" button. In simulator there is an alert displayed asking to sign in with your apple id. Please see attached Image in URL

Image


Solution

  • This alert is part of the Springboard so to handle it you can use either:

    let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
    springboard.alerts["Sign in with your Apple ID").buttons["Close"].tap()
    

    or

    let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
    springboard.alerts.element(boundBy: 0).buttons["Close"].tap()