UI自动化工具可以从命令行运行吗?

发布于 2024-10-02 15:27:49 字数 215 浏览 7 评论 0原文

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

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

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

Is there a way to open the UIAutomation instrument through the terminal?

Will it be possible to write an AppleScript to open Apple's UIAutomation tool and load the application to be tested?

Can you please tell me is there any way through scripting or through the command line we can open UIAutomation and select the app to be tested, as well as select the test script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

春庭雪 2024-10-09 15:27:49
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>

对于 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>

对于 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>

不过,有一些重要的事情需要注意:

  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 编写的自动化脚本的完整路径。另请记住将此路径放在双引号中。

  4. 最后输出结果路径是你要保存输出结果的路径。另外记得将此路径放在双引号中。

这些是我遗漏的要点,因此出现了上面提到的一些错误。

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>

for 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>

for 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>

There a few important things to note though:

  1. the -w parameter is not required unless you want to run the scripts on your device. If you want to run your scripts on the simulator, simply omit this parameter from the command.
  2. full_path_to_application is the path to your .app file that is created by your simulator. For me, the path was

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

    this path might be different for anyone else depending on what iOS version are you running on your simulator. Also remember to put this path in double quotation marks.

  3. The path_to_script.js should be the FULL PATH to where your automation script written in javascript is saved. Also remember to put this path in double quotation marks.

  4. Lastly output results path is the path where you want to save the output results. Also remember to put this path in double quotation marks.

These were the points I had been missing on and thus was getting some of the errors mentioned above.

穿透光 2024-10-09 15:27:49

通过命令行启动 UIAutomation
您现在就可以做到这一点,从 iOS5 beta 4 的 XCode 4.2 开始
从命令行,您可以运行指向自动化模板的工具,并将要执行的测试脚本和结果的目标路径指定为环境变量:

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 吗?

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

Starting UIAutomation via command line
You can do it now, starting with XCode 4.2 for iOS5 beta 4
From command line, you can run instruments pointing to the automation template and specify as environment variables the test script you want to execute and destination path for results:

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

Above is from this source url:
http://dev-ios.blogspot.com/2011/07/starting-uiautomation-via-command-line.html

See some more details on command line from Apple at:
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/instruments.1.html

Plus post from Stacktrace user on command line run with iphone iOS UIAutomation
Can Instruments be used using the command line?

Hope this helps- have a good day :)

何以笙箫默 2024-10-09 15:27:49

针对 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/'

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

您可以在 github 上找到该项目以及配套的 博客文章

Updated and tested for 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/'

Inspired by others who wrote command-line wrappers that haven't been updated in a while, and thus didn't work (and seemed difficult to make sense of as I was tempted to resurrect them), I wrote a bash shell script that I believe will be more transparent, lighter and thus, easier to maintain.

You can find the project on github and a companion blog post.

迷乱花海 2024-10-09 15:27:49

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

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

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

Instead of the long instruments command, I wrote a wrapper that is easier to use: https://github.com/enriquez/uiauto

To use it, you just have to do the following:

  1. Build your project in Xcode for the simulator (device support coming soon).
  2. cd to where your project's .xcodeproj or .xcworkspace is located.
  3. Run uiauto exec path/to/your/script.js.
幽蝶幻影 2024-10-09 15:27:49

对于每个新版本的 Xcode,模板路径似乎都发生了变化。查找模板路径的最佳方法之一是 instruments -s 命令,该命令会列出所有可用的模板。

With every new version of Xcode the template path seems to be changed. One of the best ways find out the path of the template is instruments -s command which would list out all the available templates.

も星光 2024-10-09 15:27:49

我对这个话题也非常感兴趣。我实际上发现的是这个 参考 这表明可以通过预定义模板、结果存储位置、运行目标设备以及其他参数从终端启动仪器。您还可以仅输入终端 instruments 来获取参数列表。

我以这种方式在 iPhone 上运行 UI Automation 并不成功。我还没有尝试过模拟器或 mac 应用程序,因为我最感兴趣的是设备。我在 此处发布了一个问题,但由于缺乏我认为没有多少人以这种方式使用仪器。

但让它运行还是有希望的,因为苹果开发者论坛上有这个简短的帖子 (您需要登录)表明可以完成。我稍后会尝试,如果成功,我将在这里发布解决方案。如果您能设法使其运行,请在此处发布您的方式,因为我(可能还有其他人)会感兴趣。

I also very intrested in this topic. What I actually found is this reference which shows that there is way to launch instruments from terminal with predefined template, location where results should be stored, and target device on which it should run, and other parameters. You can also just type in terminal instruments to get parameters list.

I was unsuccessful with running UI Automation on iPhone this way. I haven't try simulator or mac app since I am mostly interested in device. I posted a question here on SO but from the lack of any response I think that not many people are using instruments this way.

But there is hope to get it running, as there is this short thread on apple developer forum (you need to log in) that suggest that it can be done. I will be trying that later, if I will succeed I will post solution here. If you will manage to make it running pleas post your way here, as I (and probably others) will be interested.

没有心的人 2024-10-09 15:27:49

有一个工具可以在 shell 环境下记录/重放 UI 事件,并且可以用 ruby​​ 编写脚本。

交互式iPhone应用程序开发
http://github.com/wookay/libcat

there's a tool for record/replay UI events with shell environment, and could writting script with ruby.

interactive iPhone application development
http://github.com/wookay/libcat

围归者 2024-10-09 15:27:49

在终端 Instruments -s 中输入此命令,输入后将获得模板路径:

instruments -t <template path> <Application file path> -e UIASCRIPT <script.js> UIARESULTPATH <result_path>

Type this command in terminal instruments -s, you get template path after type:

instruments -t <template path> <Application file path> -e UIASCRIPT <script.js> UIARESULTPATH <result_path>
情独悲 2024-10-09 15:27:49

在iOS模拟器上正确的做法如下:

instruments -w 'iPhone 5s (9.1)' \
-t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
'justTheNameOfYourAppDontAddExtension' \
-e UIASCRIPT '/Users/barry/Dropbox/Public/login.js' \
-e UIARESULTSPATH '/Users/barry/Dropbox/Public/

The right way to do it on a iOS simulator is as follows:

instruments -w 'iPhone 5s (9.1)' \
-t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
'justTheNameOfYourAppDontAddExtension' \
-e UIASCRIPT '/Users/barry/Dropbox/Public/login.js' \
-e UIARESULTSPATH '/Users/barry/Dropbox/Public/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文