iOS UIAutomation:是否可以将屏幕截图与参考图像进行比较?
标题已经解释了。我正在寻找一种解决方案,将 UIAutomation 脚本中使用 target.captureScreenWithName 拍摄的屏幕截图与一些参考图像进行比较。这对于测试一些自定义视图来说非常好。
The title explains it already. I'm looking for a solution to compare screenshots taken with target.captureScreenWithName in a UIAutomation script to some reference images. This would be really nice to test some custom views.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用免费的 Mac 版 ImageMagicK。从 iOS 5 开始,有一个新的 UIAHost.performTaskWithPathArgumentsTimeout(path, args, timeout) 允许您直接从测试运行外部任务。只需使用此函数和参数运行 ImageMagic 脚本,您就可以直接从测试中获得图像比较结果。
path - 图像比较脚本的字符串;
args - ImageMagicK 实用程序的参数及其值的数组,例如:
ImageMagicK 的更多详细信息:
http://www.imagemagick.org/script/index.php
UIAHost 参考:
http://developer.apple.com/库/ios/#documentation/UIAutomation/Reference/UIAHostClassReference/UIAHost/UIAHost.html
Try to use free ImageMagicK for Mac. Starting from iOS 5 there is a new UIAHost.performTaskWithPathArgumentsTimeout(path, args, timeout) that allows you to run external task right from your tests. Simply running ImageMagic script using this functions with parameters you will be able to get image comparison results right from your test.
path - string to the image comparison script;
args - an array of parameters and its values for ImageMagicK utility like:
More details for ImageMagicK:
http://www.imagemagick.org/script/index.php
UIAHost reference:
http://developer.apple.com/library/ios/#documentation/UIAutomation/Reference/UIAHostClassReference/UIAHost/UIAHost.html
直接从UIA做是不可能的,至少我没有找到任何方法来做到这一点。所有屏幕截图都保存到测试结果文件夹中。然后您可以使用任何您喜欢的工具来处理它们。
It is impossible to do it directly from UIA, at least I didn't find any way to do this. All the screenshots are saved to the test result folder. You can then process them by any tool you like.
查看 Zucchini 框架。它很好地包装了 UIAutomation API,并允许您将屏幕截图作为测试断言。
Check out Zucchini Framework. It wraps UIAutomation API nicely and lets you have screenshots as test assertions.