I'm beginning to dip my toes into Swift alongside writing UI tests and am having a problem with typing text into a textField. Below is the code:
func testLoginUsernameField() {
let app = XCUIApplication()
app.launch()
let username = "testusername2"
let usernameField = app.textFields["username_field"]
XCTAssertTrue(usernameField.exists)
usernameField.tap()
usernameField.typeText(username)
XCTAssertEqual(usernameField.value as! String, username)
}
The problem occurs when I do usernameField.typeText(username)
. My text continues to write tstusername2
rather than the testusername2
.
tap()
. – ExpatriateNeither element nor any descendant has keyboard focus
error. – Larsentap()
(obviously) and insert a 5-second pause before thetypeText
(I'm assuming you know how to do that). Does that help? – Expatriatefor c in username {usernameField.typeText(String(c))}
? – Expatriate