Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61774

UITest. How to check if keyboard exists?

XCTAssertTrue(app.keyboards.elementBoundByIndex(0).exists) causes crash. How to do this then? Is it possible to check whether keaboard exists at all?

Upvotes: 1

Views: 1624

Answers (2)

onmyway133
onmyway133

Reputation: 48085

Another way is to check if the textField contains Keyboard Focused

let emailTextField = app.textFields.element(boundBy: 0)
XCTAssertTrue(emailTextField.debugDescription.contains("Keyboard Focused")))

Upvotes: 0

Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61774

XCTAssertEqual(app.keyboards.count, 1) - keyboard exists. XCTAssertEqual(app.keyboards.count, 0) - keyboard doesn't exists.

Upvotes: 5

Related Questions