How to capture a text value from an UI label / Textfield using accessibility ID in EarlGrey?

502 Views Asked by At

I am using EarlGrey framework but not sure which will be the method used to capture text value from an UI lable/ Textfield when using accessibility ID.

1

There are 1 best solutions below

4
Glenn Posadas On

You can use grey_accessibilityID("") Like so:

class MyFirstEarlGreyTest: XCTestCase {

  func testExample() {

    EarlGrey
      .select(elementWithMatcher: grey_accessibilityID("phone_number_text_field"))
      .assert(grey_sufficientlyVisible())
      .perform(grey_replaceText("1234"))
  }
}

I hope this helps!