排毒:iOS模拟器如何确认警报信息
我正在使用来自react-native的Alert。
如何通过按警告消息上的“注销”按钮进行排毒?
我尝试使用await element(by.text('Log out')).tap();
但我得到“多个元素匹配”的错误。 据推测,它找到3个具有相同标签的元素。 带有标签“Log out”的原始按钮用于触发警报消息,警报消息标题以及我想排毒按下的警告消息按钮。
Error Trace: [ { "Description" : "Multiple elements were matched: ( "", "", "" ). 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()
,但这意味着每次更改某些内容时我都需要使用索引来确定正确的元素。
有没有更好的方法来解决这个问题?
谢谢。
经过一些修修补补后,我最终使用了这个:
await element(by.label('Log out').and(by.type('_UIAlertControllerActionView'))).tap();
不确定这是否适用于每个iOS版本,但似乎适用于10.3和11.1