我是iPhone Automation的新手,也是iOS4推出的UIAutomation框架.最近我使用UIAutomation通过仪器在iPhone模拟器上自动测试应用程序,但它给我一个错误,如"[UIATarget_0x5a20d20 frontMostApp]中的意外错误,/ SourceCache/UIAutomation_Sim/UIAutomation-37/Framework/OUATargetElements.m第437行"
我也尝试过用iOS4更新后在iPhone 3G设备上运行应用程序.但仪器向我显示警告"此设备不支持自动化".
我的问题是,UIAutomation是否可以在模拟器上运行?我是否需要购买3GS或iPhone 4.0等新设备才能运行?提前致谢...
我有一个简单的函数,应该检查视图是否在home接口,如果没有,将它带到家里:
function returnHome() {
if (UIATarget.localTarget().frontMostApp().navigationBar().name() == mainTitle) return true;
// set tab bar to calculations
UIALogger.logMessage("Set tab bar to main.");
if (UIATarget.localTarget().frontMostApp().tabBar().selectedButton().name() != mainTabName) {
UIATarget.localTarget().frontMostApp().tabBar().buttons()[mainTabName].tap();
}
// go back to the home
UIALogger.logMessage("Go back to home.");
var backButton = UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Back"];
if (backButton.isValid()) {
backButton.tap();
} else {
UIALogger.logError("Could not find 'Back' button!");
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我无法通过错误"无法找到'返回'按钮!".它在那里,在左角,盯着我,嘲弄我!
在UIATarget.localTarget().frontMostApp().logElementTree()给了我下面的树:
2) UIAApplication [name:MyApplication value:(null) rect:{{x:0, y:20}, {width:320, height:460}}]
3) UIAWindow [name:(null) value:(null) rect:{{x:0, y:0}, {width:320, height:480}}]
4) UIAImage [name:(null) value:(null) …Run Code Online (Sandbox Code Playgroud) 当我使用for循环时,调用UIATarget.localTarget().frontMostApp().mainWindow().elements(); 要搜索主视图上的特定元素,它运行速度非常慢.有没有人遇到过这个问题呢?如果是这样,任何提糖
我正在使用UIAutomation,通过Xcode的Instruments,在iPhone上做一些事情,并得到了一个奇怪的例外:UIATargetHasGoneAWOLException.
有人知道这个例外是什么意思吗?
1)UIATarget [name:(null)value:(null)NSRect:{{2.7520829e-39,2.0667855e-36},{0,1.4012985e-45}}]
2)UIAApplication [name:tosh.0 value:(null)NSRect:{{0,20},{320,460}}]
3)UIAWindow [name:(null)value:(null)NSRect:{{0,0},{320,480}}]
4)....
5)....
3)UIAWindow [name:(null)value:(null)NSRect:{{0,0},{320,480}}]
4)UIAAlert [name:(null)value:(null)NSRect:{{18,180},{284,141}}]
5)UIAStaticText [名称:无法连接值:(null)NSRect:{{30,225},{260,21}}]
5)UIAButton [名称:OK值:( null)NSRect:{{29,262},{262,43}}]
请问如何在第二个UIAWindow上按"OK".给出语法.