[英]how to check alert view displayed in xctest case in xcode
I need to show alert on screen for any validation case and is working fine. 任何验证案例,我都需要在屏幕上显示警报,并且工作正常。 But when working with
XCTest
I am not able to detect if alert is shown. 但是当使用
XCTest
时,我无法检测是否显示警报。 How can I check UIAlertView
or UIAlertController
in XCTest
case in Xcode
. 如何在
Xcode
XCTest
案例中检查UIAlertView
或UIAlertController
。 please give any suggestions 请提出任何建议
You can use addUIInterruptionMonitor
to handle UIAlertController
in XCTest
. 您可以使用
addUIInterruptionMonitor
来处理UIAlertController
中的XCTest
。
let handler = addUIInterruptionMonitor(withDescription: "alert handler") { (alert: XCUIElement) -> Bool in
let ok = alert.buttons["OK"]
XCTAssertTrue(ok.exists, "OK button doesn't exist")
ok.tap()
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.