Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UIAutomation: is it possible to compare screenshots to reference images?

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.

like image 585
V1ru8 Avatar asked Nov 09 '10 16:11

V1ru8


2 Answers

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.

var result = UIAHost.performTaskWithPathArgumentsTimeout(path, args, timeout)

path - string to the image comparison script;

args - an array of parameters and its values for ImageMagicK utility like:

var args = ['param1', 'param1Value', 'param2', 'param2value'....];

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

like image 175
Sh_Andrew Avatar answered Nov 14 '22 18:11

Sh_Andrew


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.

like image 1
Sergey Avatar answered Nov 14 '22 17:11

Sergey