Swift UI Test - alert user alerts

I am trying to get a warning from a user alert system by following the thread presented in the next post, which is the same thread that is mentioned in the UI test cheat sheets and a few other posts in SO.

Xcode7 | Xcode Interface Tests | How to deal with location alerts?

I have a strange problem when I cannot click the OK button. Here is my code

    addUIInterruptionMonitorWithDescription("User Notifications") { (alert) -> Bool in
        let okButton = alert.buttons["OK"]
        let dontAllowButton = alert.buttons["Don\u{2019}t Allow"]

        print(okButton.frame)
        print(dontAllowButton.frame)

        okButton.tap() // Taps the dontAllowButton ??

        return true
    }

    launchFinished() // wait for app to load and notification to show
    app.tap()

The test passes successfully in the handler after I use app.tap(), and the buttons are found and exist, however, it seems that it cannot actually click OK! When I try to click the OK button, she clicks the Allow button, and when I try to click the Allow button, she doesn't click anything.

, .

Alert buttons for notifying users

, :

okButton = (431,5, 377,0, 44,0, 135,0)

dontAllowBtn = (431,5, 512,0, 44,0, 135,0)

, X, - , .

, XCUICoordinate, , , , , .

?

Xcode 7.1.1, . , - , . , . , .

2

Apple.

+4

Source: https://habr.com/ru/post/1619366/


All Articles