【问题标题】:Unable to run command line for iOS UI Automation无法为 iOS UI 自动化运行命令行
【发布时间】:2016-01-02 18:33:42
【问题描述】:
我使用了这个网站的模板:http://blog.manbolo.com/2012/04/08/ios-automated-tests-with-uiautomation,并创建了我自己的命令行来在终端上运行自动化测试。
以下是关于我的脚本的一些有用信息:
我使用的是 xCode 6.4。
我在 Xcode 仪器中运行了这个自动化脚本,它运行良好。
这是我的命令行:
instruments -w 927b666816e2d4377b208a872b42a1d3xxxxxxxx -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate ConsumeriOS -e UIASCRIPT/Users/wendywang/Documents/ TIO/ConsumeriOS/ConsumeriOS/ConsumeriOSTests/automationScript/LogIn.js
但是我收到了这个错误:
2015-10-05 14:16:34.122 仪器[23330:551118] WebKit 线程违规 - 从辅助线程初始使用 WebKit。仪器使用错误:无法解析仪器“自动化”仪器的目标,版本 6.4 (57082) 用法:仪器 [-t 模板] [-D 文档] [-l timeLimit] [-i #] [-w 设备] [[ -p pid] | [应用程序 [-e 变量值] [参数 ...]]] tio-spare:~ wendywang$ ConsumeriOS -e UIASCRIPT /Users/wendywang/Documents/xxx/ConsumeriOS/ConsumeriOS/ConsumeriOSTests/automationScript/LogIn.js -bash: ConsumeriOS:找不到命令
我仔细检查了
- UDID 正确
- 自动跟踪模板位于正确的路径中
- LogIn.js 文件的路径正确
有一件事我不确定:
ConsumeriOS 是代码的名称。但在代码内部,它实际上可以生成一些应用程序。我正在测试名为 Consumer 的应用程序。所以我不确定是否应该将 ConsumeriOS 写为应用程序的名称,或者改为 Consumer。
有谁知道它为什么会产生这个错误?谢谢!
【问题讨论】:
标签:
ios
xcode
command-line
ios-ui-automation
【解决方案1】:
相关消息是这样的:
tio-spare:~ wendywang$ ConsumeriOS -e UIASCRIPT /Users/wendywang/Documents/xxx/ConsumeriOS/ConsumeriOS/ConsumeriOSTests/automationScript/LogIn.js -bash: ConsumeriOS:找不到命令
看来你可能复制粘贴了这个命令:
instruments -w 927b666816e2d4377b208a872b42a1d3xxxxxxxx -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate ConsumeriOS -e UIASCRIPT/Users/wendywang/Documents/ TIO/ConsumeriOS/ConsumeriOS/ConsumeriOSTests/automationScript/LogIn.js
但不正确——分两部分,第 1 部分:
instruments -w 927b666816e2d4377b208a872b42a1d3xxxxxxxx -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate
第 2 部分(由换行符分隔):
ConsumeriOS -e UIASCRIPT/Users/wendywang/Documents/TIO/ConsumeriOS/ConsumeriOS/ConsumeriOSTests/automationScript/LogIn.js
另外,您似乎写了应用的名称 (ConsumeriOS),而不是应用的完整路径 (/path/to/ConsumeriOS.app)。
【解决方案2】:
呼呼,
试试这个:
给个
- 带有 .app 扩展名的应用的完整路径,
- 将DeviceID和脚本放入“”,
- 尝试使用设备名称,如果没有
工作。
这里有一个适合我的示例。
instruments -w "DeviceID" -t PATHTOTEMPLATE/Automation.tracetemplate PATHTOAPP/ConsumeriOS.app -e UIASCRIPT "PATHTOSCRIPT/UITest.js"
告诉我!