I watched the WWDC talk on UITesting a couple of times. Used the accessibility fields in Interface Builder to give the buttons and labels names. Got recording working. I am writing a simple calculator app. It has buttons and a UILabel for its display. The problem is that I can't seem to find the property of the UILabel which contains its current text.
let app = XCUIApplication() app.buttons["OneKey"].tap() app.buttons["TwoKey"].tap() app.buttons["ThreeKey"].tap() XCTAssertEqual(app.otherElements["MainDisplay"].value as? String, "123", "Whole number Entry-Main Display")
Assertion Failure: XCTAssertEqual failed: ("Optional("")") is not equal to ("Optional("123")") - Whole number Entry-Main Display Optional("Main Display")
The assertion fails and says that the MainDisplay text is "" blank. I used the debugger to dump the .debugDescription of the staticTexts and can find no useful properties. I tryed .value, .textFields, .description
(lldb) p print(app.otherElements["MainDisplay"].staticTexts as? String) nil (lldb) p print(app.otherElements["MainDisplay"].textFields as? String) nil (lldb) p print(app.otherElements["MainDisplay"].value as? String) Optional("")
Anyone know what I am doing wrong?
By The Way, whats with the illegal characters error when it doesn't like your title?