Hi,
I've ha some success using ChunkyPNG and the inbuilt screenshot functionality
of calabash:
http://jeffkreeftmeijer.com/2011/comparing-images-and-creating-image-diffs/
I’ve managed to use it to compare two pngs and the results are fairly accurate.
I only had to come up with 4 lines of code and that was just to generate the images to compare.
But be warned its pretty slow...
JitGHi,
I've ha some success using ChunkyPNG and the inbuilt screenshot functionality of calabash:http://jeffkreeftmeijer.com/2011/comparing-images-and-creating-image-diffs/
I’ve managed to use it to compare two pngs and the results are fairly accurate.
This is working for me (the partial search is a lot slower and I'm not that sure that it is actually working):
# Uses imagemagik to find the compare the current screenshot against a known-good
Then /^the current screen should resemble the screenshot "([^\"]+)"$/ do | known_good |
new_screenshot = screenshot()
diff_img = new_screenshot.sub(/\.png$/, '_diff.png')
out = `compare -metric AE \"#{new_screenshot}\" \"iphone/features/support/#{known_good}\" \"#{diff_img}\" 2>&1`
FileUtils.rm( new_screenshot )
if( out == "0\n" )
FileUtils.rm( diff_img )
else
embed( File.basename(diff_img), 'image/png')
raise('Current screen differs from known-good')
end
end
# Uses imagemagik to find the specified subimage within the current screenshot
# This is much slower than the full-screen comparison
Then /^I should see the partial screen shot "([^\"]+)"$/ do | partial |
new_screenshot = screenshot()
diff_img = new_screenshot.sub(/\.png$/, '_diff.png')
out = `compare -metric AE -subimage-search \"#{new_screenshot}\" \"iphone/features/support/#{partial}\" \"#{diff_img}\" 2>&1`
FileUtils.rm( diff_img ) if File.exists?(diff_img) # (It probably won't)
if( out == "0\n" )
FileUtils.rm( new_screenshot )
else
embed( File.basename(new_screenshot), 'image/png')
raise("Can not find partial screenshot within the current screen")
end
end