【问题标题】:UIAutomation - different results from Instruments and Command LineUIAutomation - 来自 Instruments 和 Command Line 的不同结果
【发布时间】:2012-12-21 07:04:23
【问题描述】:

当我在 Instruments 中运行 UIAutomation 脚本时,一切正常,但是当我从命令行运行完全相同的脚本时,出现以下错误: Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().tableViews()[0].cells()["ID number, Required"].textFields()[0]

这是我用来启动测试的 Instruments 命令

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 

【问题讨论】:

  • 你能发布你用来启动测试的仪器命令吗?命令行启动的环境与 Instruments GUI 应用程序使用的环境可能存在某种差异。
  • Xcode 版本是多少?在 Xcode 4.5.2 中,一个类似的命令似乎对我有用,我的构建配置设置为 Release,iPhone 6.0 模拟器作为目标。也许尝试将您的方案切换到调试构建配置,构建,然后将您的仪器命令中的“Release-iphonesimulator”替换为“Debug-iphonesimulator”?

标签: iphone command-line instruments ui-automation ios-ui-automation


【解决方案1】:

原因可能是 Instruments 下的 UIAutomation 比从命令行运行时慢得多。所以可能是在仪器下元素 target.frontMostApp().mainWindow().tableViews()[0].cells()["ID number, Required"].textFields()[0]
存在,即有效,但从控制台还没有。
也许您应该尝试等待元素变为有效,然后再对其执行操作,以检查其有效性(isValid)并记录它以确保其状态。

【讨论】:

    猜你喜欢
    • 2016-08-13
    • 1970-01-01
    • 1970-01-01
    • 2020-03-17
    • 1970-01-01
    • 2016-03-07
    • 1970-01-01
    • 2022-01-05
    • 2012-03-31
    相关资源
    最近更新 更多