Tikky Posted April 14, 2008 Share Posted April 14, 2008 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. Link to comment Share on other sites More sharing options...
spudw2k Posted April 14, 2008 Share Posted April 14, 2008 (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 April 14, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Tikky Posted April 15, 2008 Author Share Posted April 15, 2008 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. Link to comment Share on other sites More sharing options...
spudw2k Posted April 15, 2008 Share Posted April 15, 2008 (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 April 15, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Tikky Posted April 15, 2008 Author Share Posted April 15, 2008 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. Link to comment Share on other sites More sharing options...
Tikky Posted April 15, 2008 Author Share Posted April 15, 2008 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. Link to comment Share on other sites More sharing options...
junkew Posted April 16, 2008 Share Posted April 16, 2008 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 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Tikky Posted April 16, 2008 Author Share Posted April 16, 2008 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. Link to comment Share on other sites More sharing options...
FreeFry Posted April 17, 2008 Share Posted April 17, 2008 What page are you trying to automate? It'd be alot easier to help you if you provide that. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now