简体   繁体   English

如何改进iPhone UI自动化?

[英]how can I improve iPhone UI Automation?

I was googling a lot in order to find a solution for my problems with UI Automation. 为了找到解决我的UI自动化问题的解决方案,我正在谷歌上搜索。 I found a post that nice summarizes the issues: 我发现了一篇很好的帖子总结了这些问题:

There's no way to run tests from the command line.(...) 没有办法从命令行运行测试。(...)

There's no way to set up or reset state. 无法设置或重置状态。 (...) (......)

Part of the previous problem is that UI Automation has no concept of discrete tests. 上一个问题的一部分是UI Automation没有离散测试的概念。 (...) (......)

There's no way to programmatically retrieve the results of the test run. 没有办法以编程方式检索测试运行的结果。 (...) (......)

source: https://content.pivotal.io/blog/iphone-ui-automation-tests-a-decent-start 来源: https//content.pivotal.io/blog/iphone-ui-automation-tests-a-decent-start

Problem no. 问题没有。 3 can be solved with jasmine ( https://github.com/pivotal/jasmine-iphone ) 3可以用茉莉花来解决( https://github.com/pivotal/jasmine-iphone

How about other problems? 其他问题怎么样? Have there been any improvements introduced since that post (July 20, 2010)? 自那篇文章(2010年7月20日)以来,是否有任何改进?

And one more problem: is it true that the only existing method for selecting a particular UI element is adding an accessibility label in the application source code? 还有一个问题:选择特定UI元素的唯一现有方法是在应用程序源代码中添加辅助功能标签吗?

While UI Automation has improved since that post was made, the improvements that I've seen have all been related to reliability rather than new functionality. 虽然自从该帖子发布以来UI自动化已经有所改进,但我所看到的改进都与可靠性而非新功能有关。

He brings up good points about some of the issues with using UI Automation for more serious testing. 他提出了使用UI自动化进行更严格测试的一些问题。 If you read the comments later on, there's a significant amount of discussion about ways to address these issues. 如果您稍后阅读评论,那么就如何解决这些问题进行了大量讨论。

The topic of running tests from the command line is discussed in this question , where a potential solution is hinted at in the Apple Developer Forums . 在命令行运行测试的话题中讨论这个问题 ,其中一个可能的解决方案是在暗示, 在苹果开发者论坛 I've not tried this myself. 我自己没试过。

You can export the results of a test after it is run, which you could parse offline. 您可以在运行测试后导出测试结果,您可以离线解析。

Finally, in regards to your last question, you can address UI elements without assigning them an accessibility label. 最后,关于您的上一个问题,您可以解决UI元素,而无需为其分配可访问性标签。 Many common UIKit controls are accessible by default, so you can already target them by name. 默认情况下可以访问许多常见的UIKit控件,因此您可以按名称对其进行定位。 Otherwise, you can pick out views from their location in the display hierarchy, like in the following example: 否则,您可以从显示层次结构中的位置中选择视图,如下例所示:

var tableView = mainWindow.tableViews()[0];

As always, if there's something missing from the UI Automation tool that is important to you, file an enhancement request so that it might find its way into the next version of the SDK. 与往常一样,如果UI自动化工具中缺少对您很重要的内容,请提交增强请求,以便它可以进入下一版本的SDK。

Have you tried IMAT? 你试过IMAT吗? https://code.intuit.com/sf/sfmain/do/viewProject/projects.ginsu . https://code.intuit.com/sf/sfmain/do/viewProject/projects.ginsu It uses the native javascript sdk that Apple provides and can be triggered via command line or Instruments. 它使用Apple提供的原生javascript sdk,可以通过命令行或工具触发。

In response to each of your questions: 回答您的每个问题:

There's no way to run tests from the command line.(...) 没有办法从命令行运行测试。(...)

Apple now provides this. Apple现在提供此功能。 With IMAT, you can kick off tests via command line or via Instruments. 使用IMAT,您可以通过命令行或通过仪器启动测试。 Before Apple provided the command line interface, we were using AppleScript to bring up Instruments and then kick off the tests - nasty. 在Apple提供命令行界面之前,我们使用AppleScript调出仪器,然后开始测试 - 讨厌。

There's no way to set up or reset state. 无法设置或重置状态。 (...) (......)

Check out this state diagram: https://code.intuit.com/sf/wiki/do/viewPage/projects.ginsu/wiki/RecoveringFromTestFailures 查看此状态图: https//code.intuit.com/sf/wiki/do/viewPage/projects.ginsu/wiki/RecoveringFromTestFailures

Part of the previous problem is that UI Automation has no concept of discrete tests. 上一个问题的一部分是UI Automation没有离散测试的概念。 (...) (......)

Agreed. 同意。 Both IMAT and tuneup.js (https://github.com/alexvollmer/tuneup_js#readme) allow for this. IMAT和tuneup.js(https://github.com/alexvollmer/tuneup_js#readme)都允许这样做。

There's no way to programmatically retrieve the results of the test run. 没有办法以编程方式检索测试运行的结果。 (...) (......)

Reading the trailing plist file is not trivial. 读取尾随的plist文件并非易事。 IMAT provides a jUnit like report after a test run by reading the plist file and this is picked up by my CI Tool (Teamcity, Jenkins, CruiseControl) 测试运行后,IMAT通过读取plist文件提供类似jUnit的报告,这是由我的CI工具(Teamcity,Jenkins,CruiseControl)选取的

Try to check the element hierarchy, the table can be placed over a UIScrollView. 尝试检查元素层次结构,该表可以放在UIScrollView上。

var tableV = mainWindowTarget.scrollViews()[0].tableViews()[0].scrollToElementWithName("Name of element inside the cell");

the above script will work even the element is in 12th cell(but the name should be exactly the same as mentioned inside the cell) 即使元素在第12个单元格中,上面的脚本也会起作用(但名称应该与单元格中提到的完全相同)

查看http://lemonjar.com/blog/?p=69它讨论了如何从命令行运行UIA

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM