I'm trying XCode for iOS UI testing. My test application has UITextView element with accessibility identifire displayTextView
.
I tried simple test that taps this element, types some text it and then check the result the following way:
XCUIElement *textView = app.textViews[@"displayTextView"];
[textView tap];
[textView typeText:@"9.9"];
It works. But then I can't get the typed text from the text view. I tried to do it by the following:
XCTAssertEqual([textView.accessibilityValue isEqualToString:@"9.9"]);
But it seems it is incorrect, because textView.accessibilityValue is null. What method would be appropriate to get the typed text?
I found the answer. The correct way is:
XCTAssert([textView.value isEqualToString:@"9.9"]);
or let text = textView.value as! String
let text = textView.value as! String
I used:
let expectedValue = "Hello World!"
XCTAssert(app.staticTexts[expectedValue].isHittable)
Using this approach, we look for labels displaying expectedValue
, and verify if it is visible...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.