簡體   English   中英

如何檢查在xcode中的xctest案例中顯示的警報視圖

[英]how to check alert view displayed in xctest case in xcode

任何驗證案例,我都需要在屏幕上顯示警報,並且工作正常。 但是當使用XCTest時,我無法檢測是否顯示警報。 如何在Xcode XCTest案例中檢查UIAlertViewUIAlertController 請提出任何建議

您可以使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM