Skip to content

Instantly share code, notes, and snippets.

@dinneo
Forked from alecsechechel/UITestOther
Created June 1, 2021 16:26
Show Gist options
  • Save dinneo/9552368c1df4d8920e95f803bda35990 to your computer and use it in GitHub Desktop.
Save dinneo/9552368c1df4d8920e95f803bda35990 to your computer and use it in GitHub Desktop.
UI Testing button, textField, allert, navigation bar
func testOther() {
let app = XCUIApplication() //create app
XCTAssertTrue(app.navigationBars.staticTexts["Title"].exists) //check navigation bar title
XCTAssertTrue(app.buttons["Test"].exists) //check button with title Test
app.buttons["Test"].tap() //tap button
XCTAssertTrue(app.alerts["Error"].exists) //check allert with title Error
app.alerts["Error"].buttons.elementBoundByIndex(0).tap()//tap first button on allert
let textField = app.textFields["nameTextField"] //choose textFields with idenificator nameTextField
textField.tap()// tap on text fields
textField.typeText("correct")// write text to textFields
app.buttons["Test"].tap()
XCTAssertTrue(app.alerts["Correct"].exists)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment