我想在iPhone模拟器和最新的iOS SDK 4.1中使用仪器中的UIAutomation。这是有问题的JavaScript片段:iPhone UIAutomation按钮不点火
// there are sufficient delays here to make sure the view is loaded
UIATarget.localTarget().frontMostApp().logElementTree();
main.buttons()["theButton"].tap();
UIALogger.logMessage("The button tapped");
for (var b = 0; b < main.buttons().length; b++)
{
UIALogger.logMessage("Button title: " + main.buttons()[b].name());
}
main.toolbar().buttons()["OK"].tap();
UIALogger.logMessage("OK tapped");
的“theButton”按钮名称在logElementTree显示出来并显示出来,当我记录所有按钮的名称,所以它是在界面生成器中正确配置,但出于某种原因,它不会被轻敲。我在脚本的前面有其他按钮可以轻松点击,如果我在非轻击按钮处中止脚本,我可以单击模拟器中的按钮并按预期工作。
编辑:在上面显示的javascript for循环中,我点击了main.buttons()数组中的每个按钮,并且视图中12个相同按钮中只有1个获取了水龙头。
而且,你想知道的话,我必须在JavaScript文件的顶部验证码:
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var main = app.mainWindow();
,这里是显示从条目的序列logElementTree付诸按钮信息的行日志消息:
4) UIAButton [name:theButton value:(null) NSRect: {{25, 93}, {74, 74}}]
我试图推动按钮以确保它仍然存在,我在按钮水龙头前至少延迟了1秒,并且我仍然没有在主窗口按钮上点击。我在按钮上做了一个logElement,它与上面的描述相同,并且OK工具栏按钮点击效果很好。你在actionSheetIsValid,actionSheetButton和tapActionSheetButtonByName函数中做了什么?谢谢。 BP – 2011-02-23 21:14:04