UI自动化仪器可以从命令行运行吗?

Vij*_*jay 54 iphone xcode applescript instruments ios-ui-automation

有没有办法UIAutomation通过终端打开仪器?

是否可以编写一个AppleScript打开Apple UIAutomation工具并加载要测试的应用程序?

您能告诉我有没有办法通过脚本或通过命令行我们可以打开UIAutomation并选择要测试的应用程序,以及选择测试脚本?

Far*_*sim 55

instruments -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/\
PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate \
<full_path_to_application> -e UIASCRIPT <path_to_script.js> \
-e UIARESULTSPATH <output_results_path>
Run Code Online (Sandbox Code Playgroud)

对于xcode> = 4.5

instruments -t
/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/\
AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate \
<full_path_to_application> -e UIASCRIPT <path_to_script.js> \
-e UIARESULTSPATH <output_results_path>
Run Code Online (Sandbox Code Playgroud)

对于xcode> = 6.1

instruments -w <device ID> -t \
/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/\
AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate \
<full_path_to_application> -e UIASCRIPT <path_to_script.js> \
-e UIARESULTSPATH <output_results_path>
Run Code Online (Sandbox Code Playgroud)

但有几点需要注意:

  1. 除非您要在设备上运行脚本,否则不需要-w参数.如果要在模拟器上运行脚本,只需从命令中省略此参数即可.
  2. full_path_to_application是模拟器创建的.app文件的路径.对我来说,路径是

    / Users/fwasim/Library/Application Support/iPhone Simulator/5.0/Applications/AA6BA2E1-D505-4864-BECC-29ADEE28194D/name_of_application.app

    根据您在模拟器上运行的iOS版本,此路径可能与其他任何人不同.还记得将此路径放在双引号中.

  3. path_to_script.js应该是保存用javascript编写的自动化脚本的FULL PATH.还记得将此路径放在双引号中.

  4. 最后,输出结果路径是您要保存输出结果的路径.还记得将此路径放在双引号中.

这些是我一直缺少的点,因此得到了上面提到的一些错误.


小智 22

通过命令行启动UIAutomation现在可以执行此操作,从XCode 4.2 for iOS5 beta 4开始从命令行,您可以运行指向自动化模板的仪器,并将要执行的测试脚本和结果的目标路径指定为环境变量:

instruments -w -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -e UIASCRIPT

以上是来自此源的网址:http: //dev-ios.blogspot.com/2011/07/starting-uiautomation-via-command-line.html

有关Apple命令行的更多详细信息,请访问:http: //developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/instruments.1.html

加上来自Stacktrace用户的命令行在iphone上运行iOS UIAutomation 可以使用命令行使用Instruments吗?

希望这会有所帮助 - 度过美好的一天:)


idS*_*tar 8

更新并测试了Xcode 6.0.1:

instruments -w 'iPhone 5s' \
    -t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
    '/Users/sohail/Library/Developer/CoreSimulator/Devices/7232A640-A9D2-4626-A2AD-37AFFF706718/data/Containers/Bundle/Application/E71B915E-051D-4BEF-9083-34416D02EC91/RoadRunnerRadar.app' \
    -e UIASCRIPT '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestRunner.js' \
    -e UIARESULTSPATH '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestResults/'
Run Code Online (Sandbox Code Playgroud)

受到其他编写命令行包装器的人的启发,这些包装器一段时间没有更新,因而无法工作(并且似乎很难理解,因为我很想复活它们),我写了一个bash shell脚本,我相信会更透明,更轻,因此更容易维护.

你可以在github上找到这个项目和一篇配套博客文章.


Mic*_*uez 6

而不是长instruments命令,我写了一个更容易使用的包装器:https://github.com/enriquez/uiauto

要使用它,您只需执行以下操作:

  1. 在Xcode中为模拟器构建项目(即将推出设备支持).
  2. cd到项目的.xcodeproj或.xcworkspace所在的位置.
  3. uiauto exec path/to/your/script.js.