2012-11-01 44 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) {} 
相关问题