2012-11-01 79 views
3

如何在Alert有Yes和No Buttons時單擊警報消息按鈕。如何選擇在IOS的警報消息中選擇哪個按鈕UIAutomation

,我嘗試的方式,如:

target.frontMostApp().alert().buttons()["buttonName"].tap(); 
target.frontMostApp().alert().buttons()["index"].tap(); 

而且也UI自動化點擊工具欄中的按鈕,並顯示以下SYN稅:當我做

target.frontMostApp().alert().cancelButtons().tap(); 

和沒有工作它手動點擊默認button.and也嘗試用下面的方式也。

target.frontMostApp().alert().cancelButtons()["index/buttonname"].tap(); 
target.frontMostApp().alert().defaultButtons()["index/buttonname"].tap(); 

如何從Alert消息中選擇Yes按鈕或NO按鈕?

回答

1

啊你需要在onAlert中使用這段代碼。

此外,您還需要在try catch塊中進行第二次敲擊。

我的代碼在哪裏用於刪除表中的一行,並確認刪除按鈕上顯示的警報。

target.frontMostApp().mainWindow() .tableViews()["Empty list"].cells()[0] 
    .dragInsideWithOptions({startOffset:{x:0.03, y:0.44}, 
    endOffset:{x:0.81, y:0.50},duration:1}); 

target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()[0] 
    .buttons()[0].tap(); 


UIATarget.onAlert = function onAlert(alert) { 
    alert.tapWithOptions({tapOffset:{x:0.73, y:0.72}}); 
} 

try { 
    target.frontMostApp().alert().tapWithOptions({tapOffset:{x:0.72, y:0.78}}); 
} 
catch (ex) {} 
相關問題