![](/img/trans.png)
[英]is there a way to manage the duration of the remote notification to be displayed longer on the banner?
[英]XCUITest Remote notification clicking on banner
我正在嘗試使用以下代碼讓XCUITest與遠程通知進行交互,但是我很好奇此代碼是否僅單擊我的應用程序通知或接收到的任何通知,具體取決於哪個先到達?
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let springBoardNotification = springboard.otherElements["NotificationShortLookView"]
let springBoardExists = springBoardNotification.waitForExistence(timeout: 150)
XCTAssert(springBoardExists)
springBoardNotification.tap()
它將單擊每個通知。 為此,我使用以下代碼:
let notification = springboardApp.otherElements.matching(NSPredicate(format: "label BEGINSWITH 'APP_NAME, now,'").firstMatch
,其中APP_NAME是顯示在通知左上方的確切標簽。
這樣,您還可以通過在最后一個逗號后添加期望的內容來測試確切的通知內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.