Sign in to follow this  
Followers 0
Tikky

Comparing Two Graphical Outputs

9 posts in this topic

I am planning to automate a test. The test result prints on IE either a passed or failed message in the following manner:

Test 1: Passed

Test 2: Passed

Test 3: Failed

Test 4: Passed

the catch is that the passed/failed is not text so I cannot search through the html source for passed/failed nor can I search for a <filename>.gif/jpeg/bmp as the filename is a randomly generated number and therefore cannot be pre-determined. My plan was to get a snapshot of a screen segment which is the appropiate size of the passed or failed message and compare it to a the passed/failed.gif file which I have previously captured and stored. The dimension of these files are 80x120 so the segment to be captured will be the same. Is there something other then pixel by pixel comparison which can compare the two images? If not can someone provide a snippet for defined size (X by Y) screen capture and a snippet for image file comparison between 2 images with an output value of (0 = match), (1 = differ)?

Any help in this matter would be appreciated.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The source should still have a static image for each result state (passed/fail). I think you can use the _IEAttach() function to work with the IE window that has the report, then you could look at the source via, _IEBodyReadHTML(). I think... Much easier than an complicated pixelcheck script.

#include <IE.au3> 
$oIE = _IEAttach ( "Google" )
$sHTML = _IEBodyReadHTML ($oIE)

msgbox(0,"",$sHTML)
Edited by spudw2k

Share this post


Link to post
Share on other sites

The OCR functionality of word seems like an interesting idea to experiment with. Although this does show potential to solve the problem at hand it would have failed if the passed was shown with a check mark image and the failed with a stop sign image what would be the solution to handle such a case. If need be a new thread could be created to handle this situation.

The problem with reading the html source is that, as I had mentioned in my initial comment, I would not be able to figure out which image represents passed and which one represents failed.

Thanks for the quick response to my initial query.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

What happens when you rightclick on either the stop sign or check mark and click properties. It should give the name of the file. I would find it hard to believe that they generate a file for this each time....but I could be wrong. Can you post some source of the result report?

Edited by spudw2k

Share this post


Link to post
Share on other sites

I tried out the OCR idea and although it seemed like a good idea the OCR functionality of word does not function as good as one would expect and sometimes converts the passed image to say "pas sed", "passd" and sometimes (not always) as "passed". The unreliability of OCR conversion makes this smart idea not usable.

Share this post


Link to post
Share on other sites

No they don't generate a new image however the page is created dynamically so the image name if you right click on it changes to some other value when the page is refreshed. It looks like they use a guid as the image name. I would try to input the new name as a input argument for the passed/failed image's variable in my au3 script everytime the page is refreshed to reflect the new value to look for but this defeats the purpose for automation.

Share this post


Link to post
Share on other sites

Slightly alternative function(s)

$String = _PassFail("Passed")
$String = _PassFail("Failed")
$String = _PassFail("Pas sed")
$String = _PassFail("Pa")
$String = _PassFail("Parsed")
$String = _PassFail("Harsed")
$String = _PassFail("Fai led")
$String = _PassFail("Faed")
$String = _PassFail("Eailed")
$String = _PassFail("Pased")
Exit 0

Func _PassFail($S)
    $String="Unknown"
    if (stringinstr($S,"P")+stringinstr($S,"s")) > 0  then $String="Passed"
    if (stringinstr($S,"F")+stringinstr($S,"i")) > 0  then $String="Failed"
    consolewrite("PassFail >" & $S & "<   = " &   $String & @CRLF)
    Return $String
EndFunc  ;==>_PassFail

;~ Les good
;~ Func _PassFail($S)
;~  $String="Unknown"
;~  if stringleft($S,1)="P" then $String="Passed"
;~  if stringleft($S,1)="F" then $String="Failed"
;~   consolewrite("PassFail >" & $S & "<   = " &   $String & @CRLF)
;~   Return $String
;~ EndFunc  ;==>_PassFail

Share this post


Link to post
Share on other sites

Thank you guys for your support I greatly appreciate your comments all of the ideas given were very good and solved my problem at hand. If we can however continue this thread to find out a solution for the case when the passed failed messages are replaced with a checkmark and a stop sign respectively it would be beneficial for me in the future and maybe someone else who might be reading this thread.

Share this post


Link to post
Share on other sites

What page are you trying to automate? It'd be alot easier to help you if you provide that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0