2016-07-07 26 views
2

我使用此代碼點擊登錄按鈕元素:grey_accessibilityLabel(「登錄」)不匹配,在UI層次結構中存在具有相同的無障礙標籤

[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel("Login")] performAction:grey_tap()]; 

但是,它失敗,出現以下錯誤:

No elements found

UI層次結構傾倒在失敗的相關因素的樣子:

<UIButton:0x7fcb01d963d0; AX=N; AX.label='Login'; AX.frame={{16, 64}, {124, 64}}; AX.activationPoint={78, 96}; AX.traits='UIAccessibilityTraitLink'; AX.focused='N'> 

單擊登錄按鈕的正確方法是什麼?

回答

4

我加AX=N matching to the EarlGrey FAQ.

How do I match elements that are denoted with "AX=N" in the view hierarchy?

EarlGrey's view hierarchy identifies non-accessible elements with AX=N . Accessibility IDs can be added to both accessible and non-accessible elements. When searching for AX=N elements, the following accessibility matchers won't work:

  • grey_accessibilityLabel
  • grey_accessibilityValue
  • grey_accessibilityTrait
  • grey_accessibilityHint

If the AX=N element can't be matched by grey_accessibilityID , then you'll have to use non-accessibility matchers to locate the element.

我修復按鈕,這樣它的訪問,則標籤匹配會工作。

相關問題