7

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?

Yulia
  • 1,087
  • 9
  • 16

3 Answers3

8

I found the answer. The correct way is:

XCTAssert([textView.value isEqualToString:@"9.9"]);
Yulia
  • 1,087
  • 9
  • 16
4

or let text = textView.value as! String

David Weiss
  • 1,842
  • 3
  • 17
  • 25
-2

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...

ezequiel
  • 197
  • 2
  • 5