swiftxcode-ui-testingui-testingearlgrey

Tapping system alert using EarlGrey 2.0 & Swift


I'm trying to create UI tests for my app using EarlGrey 2.0 framework while using Swift language for those tests. However, I can't find a solution for tapping on a system alert, although EG 2.0 should support them. To be more specific, it is the native location iOS permission dialog when the app launches. Has anyone done this already? Any ideas? Thank you.


Solution

  • Here's the full code of a test accepting native system alert in Swift

    func testExample() {
        let app = XCUIApplication()
        app.launch()
        XCTAssertTrue(grey_wait(forAlertVisibility: true, withTimeout: 2))
        XCTAssertTrue(grey_acceptSystemDialogWithError(nil))
        XCTAssertTrue(grey_wait(forAlertVisibility: false, withTimeout: 1))    
    }