我正在使用来自 react-native 的警报。
如何排毒以按警报消息上的“注销”按钮?
我尝试使用await element(by.text('Log out')).tap();
但我得到“多个元素匹配”错误。大概它会找到 3 个具有相同标签的元素。带有“注销”标签的原始按钮用于触发警报消息、警报消息标题和我要排毒的警报消息按钮。
Error Trace: [
{
"Description" : "Multiple elements were matched: (
"<UILabel:0x7fe7964db910; AX=Y; AX.label='Log out'; AX.frame={{41, 234}, {238, 20.5}}; AX.activationPoint={160, 244.25}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{16, 20}, {238, 20.5}}; opaque; alpha=1; UIE=N; text='Log out'>",
"<UILabel:0x7fe7964dda90; AX=Y; AX.label='Log out'; AX.frame={{198.5, 322.5}, {58, 20.5}}; AX.activationPoint={227.5, 332.75}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{0, 12}, {58, 20.5}}; opaque; alpha=1; UIE=N; text='Log out'>",
"<RCTText:0x7fe79652f300; AX=Y; AX.label='Log out'; AX.frame={{16, 338.5}, {288, 17}}; AX.activationPoint={160, 347}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{0, 0}, {288, 17}}; alpha=1>"
). Please use selection matchers to narrow the selection down to single element.",
"Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
"Error Code" : "5",
"File Name" : "GREYElementInteraction.m",
"Function Name" : "-[GREYElementInteraction grey_errorForMultipleMatchingElements:withMatchedElementsIndexOutOfBounds:]",
"Line" : "956"
}
]
我想一种方法是使用.atIndex()
,但这意味着每次发生变化时我都需要使用索引来确定正确的元素。
没有更好的方法来解决这个问题吗?
谢谢。