首页 > 解决方案 > 如何使用 EarlGrey 中的辅助功能 ID 从 UI 标签/文本字段中捕获文本值?

问题描述

我正在使用 EarlGrey 框架,但不确定使用可访问性 ID 时从 UI 标签/文本字段中捕获文本值的方法。

标签: iosswiftxcuitestearlgrey

解决方案


你可以grey_accessibilityID("")像这样使用:

class MyFirstEarlGreyTest: XCTestCase {

  func testExample() {

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

我希望这有帮助!


推荐阅读