5

当我运行在Instruments的UIAutomation脚本,一切工作正常,但是当我运行命令行完全一样的剧本,我得到这个错误: Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().tableViews()[0].cells()["ID number, Required"].textFields()[0]UIAutomation - 从仪器和命令行不同的结果

这里该仪器命令我使用启动测试

instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate /Users/johan/Library/Developer/Xcode/DerivedData/Brokers-etvmwznhcjprybdekgtixzzsnbrw/Build/Products/Release-iphonesimulator/MyApp -e UIASCRIPT /Users/johan/Desktop/Script.js 
+0

你可以发布你用来启动测试的仪器命令吗?也许在命令行启动环境与Instruments GUI应用程序使用的环境中有某种差异。 –

+0

什么是Xcode版本?类似的命令在Xcode 4.5.2中似乎适用于我,我的构建配置设置为Release,iPhone 6.0仿真器作为目标。也许尝试将你的方案切换到Debug构建配置,编译,然后用你的仪器命令中的“Release-iphonesimulator”替换为“Debug-iphonesimulator”? –

回答

1

的原因可能是下文书UIAutomation是在命令行中运行时相比,要慢得多。所以它可能是在工具下的元素target.frontMostApp()。mainWindow()。tableViews()[0] .cells()[“ID number,Required”]。textFields()[0]
exists,ie is有效,但从控制台尚未。
也许你应该尝试等待元素变为有效,然后再对其执行操作,检查其有效性(isValid)并记录它以确定其状态。

相关问题