我正在爲我的應用程序進行自動化UI測試,並且在嘗試設置運行測試環境時遇到了問題。該計劃大致是這樣的:在iOS模擬器上初次啓動時關閉警報
- 構建應用程序
- 關機模擬器如果運行
- 刪除模擬器做一個乾淨的安裝
- 在模擬器上安裝我的應用程序
- 運行UIAutomation測試
除了當儀器啓動應用程序以執行測試時,一切正常,警報似乎詢問是否用戶允許通知。這一切都如預期,但我無法找到擺脫警報的方式。
事情我已經嘗試:
- 創建onAlert在我的測試腳本中的第一件事情,如果它出現在我的警惕回調的情況下,定義
- 延遲目標由前5秒實際測試運行,即使之前的應用程序的UI是在模擬器
我也是通過上面所有的排列組合就可見可在SO被發現,我從來沒有讓我的onAlert調用的回調,不管是什麼我做。所以,我想另一件事是:
- 嘗試駁回警報使用AppleScript
我寫的劇本:
tell application "System Events"
tell process "iOS Simulator"
set allUIElements to entire contents of window 1
repeat with anElement in allUIElements
try
log anElement
end try
end repeat
end tell
end tell
並顯示:
static text 「MyApp」 Would Like to Send You Notifications of window iOS Simulator - iPhone 6 - iPhone 6/iOS 8.1 (12B411) of application process iOS Simulator
static text Notifications may include alerts, sounds, and icon badges. These can be configured in Settings. of window iOS Simulator - iPhone 6 - iPhone 6/iOS 8.1 (12B411) of application process iOS Simulator
UI element 3 of window iOS Simulator - iPhone 6 - iPhone 6/iOS 8.1 (12B411) of application process iOS Simulator
看起來像按鈕放置在「UI元素3」中,但我無法從i中檢索任何元素放棄它,更不用說點擊它了。所以,我有無障礙經理檢查:
它坐在那裏,作爲一個孩子,其他的人都通知的標題和消息。但是,當我去那個元素,突出顯示它,我看到:
它認定爲一般元素,它沒有任何的孩子...... 有趣的是,當我選擇在輔助功能檢查OK按鈕,我可以清楚地看到它的窗口的子窗口,但它永遠不會上市:
可有人請闡明這是怎麼回事一些輕?我怎樣才能用Applescript按下那個按鈕?