[英]How to dismiss a popover in a UI Test
I have a view controller that is presented using a "Present As Popover" segue.我有一个使用“Present As Popover”segue 呈现的视图控制器。 When I run the app it works as expected and tapping outside of the popover will dismiss it.
当我运行该应用程序时,它会按预期工作,并且在弹出窗口之外点击将关闭它。 However, when I run my UI test, I can't get the popover to dismiss.
但是,当我运行 UI 测试时,我无法消除弹出窗口。 How should I do this?
我该怎么做? I've tried:
我试过了:
app.otherElements["PopoverDismissRegion"].tap()
But the logs print:但日志打印:
Unable to find hit point for Other 0x61000017f8c0: traits: 35184372088832, {{0.0, 0.0}, {375.0, 667.0}}, identifier: 'PopoverDismissRegion', label: 'dismiss popup'
无法找到其他 0x61000017f8c0 的生命值:特征:35184372088832,{{0.0, 0.0},{375.0, 667.0}},标识符:'PopoverDismissRegion',标签:'dismiss popup'
There's a bug in Xcode UI Tests recording. Xcode UI 测试记录中存在错误。
Popover dismissal is recorded as: Popover解雇记录为:
app.otherElements["PopoverDismissRegion"].tap()
In reality the following is needed (as revealed by Accessibility Inspector):实际上需要以下内容(正如 Accessibility Inspector 所揭示的那样):
app.otherElements["dismiss popup"].tap()
Handy extension:方便的扩展:
extension XCUIApplication {
func dismissPopup() {
otherElements["dismiss popup"].tap()
}
}
在要关闭弹出窗口的位置添加此行
app.children(matching: .window).element(boundBy: 0).tap()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.