Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismiss iOS 13 keyboard tutorial when running on a fresh simulator

I am using Xcode 11 & iOS 13 as part of a workflow for a UITest, but when I engage with the keyboard for the first time, the following appears and disrupts the test by blocking the keyboard:

Calling code in UI test:

app.textFields.element(boundBy: 0).tap()

What the simulator shows: enter image description here

Since this obstructs the keys, my test will then fail. However, the next time I run the test on the same simulator, it will work properly.

like image 240
CodeBender Avatar asked Dec 28 '25 22:12

CodeBender


1 Answers

CodeBender's answer is nice and leads down the right path, but doesn't compile since continue is a reserved keyword in Swift. Plus it would be nice to wait a small amount of time for the keyboard to show up.

    // Sometimes the Apple Keyboard shows some sort of "Swipe" tutorial. Dismiss it!
    private func begoneSwipeTutorial(app: XCUIApplication) {
        let continueButton = app.buttons["Continue"]
        if continueButton.waitForExistence(timeout: 2.0) {
            continueButton.tap()
        }
    }

    // Then use like this
    func inputTextWhatever(app: XCUIApplication, element: XCUIElement) {
        element.tap()
        begoneSwipeTutorial(app: app)
        // Do whatever you need to do
    }
like image 127
Erik Zivkovic Avatar answered Dec 31 '25 13:12

Erik Zivkovic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!