I am making a UITest
in Xcode. When I record my test it works fine but when I run the test, it gives an error.
These are the lines of code where the error occurs:
XCUIElement *clearTextTextField = [app.textFields containingType:XCUIElementTypeButton
identifier:@"Clear text"].element;
[clearTextTextField typeText:@"sheffield"];
The error says
UI Testing Failure - No matches found for textfield
I imagine this is because my Text Field does not have any initial string and the tester cannot find a text box with initial string "Clear Text"
.
I watched the following tutorial on youtube.
The demonstrators code turns out fine because his textfield has an initial string. (At least that is what I think the problem is)
Is there a way to make the test work for empty text fields?
Accessibility Identifier
in Interface Builder and it will find it, even when it's empty. – chedabob