UI自动化工具可以从命令行运行吗?
有没有办法通过终端打开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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
对于 xcode >= 4.5
对于 xcode >= 6.1
不过,有一些重要的事情需要注意:
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 版本。另请记住将此路径放在双引号中。
path_to_script.js 应该是保存用 javascript 编写的自动化脚本的完整路径。另请记住将此路径放在双引号中。
最后输出结果路径是你要保存输出结果的路径。另外记得将此路径放在双引号中。
这些是我遗漏的要点,因此出现了上面提到的一些错误。
for xcode >= 4.5
for xcode >= 6.1
There a few important things to note though:
full_path_to_application is the path to your .app file that is created by your simulator. For me, the path was
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.
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.
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.
通过命令行启动 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 :)
针对 Xcode 6.0.1 进行了更新和测试:
受到其他人编写的命令行包装器的启发,这些包装器已经有一段时间没有更新了,因此不起作用(并且似乎很难理解)我很想复活它们),我编写了一个 bash shell 脚本,我相信它会更透明、更轻,因此更容易维护。
您可以在 github 上找到该项目以及配套的 博客文章。
Updated and tested for Xcode 6.0.1:
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.
我编写了一个更易于使用的包装器,而不是冗长的
instruments
命令:https://github.com/ enriquez/uiauto要使用它,您只需执行以下操作:
Instead of the long
instruments
command, I wrote a wrapper that is easier to use: https://github.com/enriquez/uiautoTo use it, you just have to do the following:
uiauto exec path/to/your/script.js
.对于每个新版本的 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.我对这个话题也非常感兴趣。我实际上发现的是这个 参考 这表明可以通过预定义模板、结果存储位置、运行目标设备以及其他参数从终端启动仪器。您还可以仅输入终端
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.
有一个工具可以在 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
在终端 Instruments -s 中输入此命令,输入后将获得模板路径:
Type this command in terminal instruments -s, you get template path after type:
在iOS模拟器上正确的做法如下:
The right way to do it on a iOS simulator is as follows: