Forum Discussion

JeanL's avatar
JeanL
Contributor
14 years ago

Highlight object and post picture to log

Hello,



Can this be done? It would be really nice to post messages with pictures to log where the selected object would be highlighted.



I've been trying this:



Set ResObject = Runner.CallObjectMethodAsync(Sys, "HighlightObject", Obj, 1, color)

aqUtils.Delay 200

 

Log.Message "Selected object", Nothing, pmNormal, Nothing, Sys.Desktop.Picture



But the problem is that it's really hard to flash the object and take a picture exactly the same time. Basically I have to adjust that Delay with every object seperately and even then I guess it's matter of luck.

8 Replies

  • Hi Jared,



    yeah I found that from Google too and tried that Vbscript code, but it gives me error (coordinates were out of bounds or something like that). I don't know about JScript code. And I noticed that Vbscript code had some differences with that JScript code.



    Do While coord < obj.Left + obj.Width
    coord=coord+1
    i=0
    Do While i < lineWidth
    i=i+1
    ScreenShot.Pixels(coord, obj.Top + i) = color
    ScreenShot.Pixels(coord, obj.Top + obj.Height - i) = color
    Loop
    Loop

    Indexes coord and i are increased at the beginning of the loop when in JScript loop they are increased at the end of the loop.



    for(var coord = obj.Left; coord < obj.Left + obj.Width; coord++)
    {
    for(var i = 0; i < lineWidth; i++)
    {
    pic.Pixels(coord, obj.Top + i) = color;
    pic.Pixels(coord, obj.Top + obj.Height - i) = color;
    }
    }

    So in example Vbscrpt index i value would be 1 on the first loop (the inner loop) when in JScripts index i  value would be 0 on the first loop. But anyhow that wasn't the part that was causing errors, just noticed the slight difference between these codes.
  • Hi,



    Actually, the VBScript version of this script was created by one of SQAforums users, and I can only guarantee that the JScript version works correctly.



    As for the error you get, I recommend that you run this function step by step and watch the values of variables on each loop iteration. Most probably, indexes run out of picture bounds somewhere.
  • Ok, I got this working with VbScript quite easily but pretty soon I bumped into new problem. When the object I want to highlight is not fully on the screen (in example huge textarea) I get this error again:



    An exception occurred in the "XXX" unit at line 123:
    The specified coordinates are out of bounds.



    Is there a way to test wheter the coordinates are out bounds or not before changing the color of the pixel with Picture.Pixels method (http://www.automatedqa.com/support/viewarticle/11131/)?



    I noticed that logs created by TC and TE has these visImage.png files. These visImages contains the screenshot with highlighted object. So that's exactly what I want!! Those pictures seems to be taken when event is posted to the log (in this case "The window was clicked with the left mouse button" event.) The log files "Has Picture" column doesn't show that this event has picture, but still it does. So what are these visImages? When are they taken? Can I control when these visImages are taken? Can I change to quality of the visImage (since the file size is quite big)? And finally, is this some new feature of TestComplete and TestExecute? Other computer I'm using has older version of TestExecute 8 and the logs created by it doesn't contain these visImages.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Jean,







    > Is there a way to test wheter the coordinates are out bounds or not [...]

    You can try .ScreenTop, .ScreenLeft, .Width and .Height properties of the tested object and compare them with the .Height and .Width of the Desktop object.



    > I noticed that logs created by TC and TE has these visImage.png files.

    These files are taken by Visualizer during record and/or playback (see relevant help topic(s) for more details). This functionality exists in all subversions of TC8. Most probably, you have it disabled on other computers (Visualizer option group in project's properties page).
  • Thanks Alexei. I've missed those Visualizer settings complitely. Would be great if one could decide when are those Visualizer images taken  in the script, just like log messages. But anyways, I got highlighting working and with .Height and .Width I can prevent coordinates from going out of bounds, thanks to you.
  • Hi Jean L,



    I am also looking for this code for very long time.



    If it started working for you. Can you please share the code with me.



    Thanks.
  • lucist's avatar
    lucist
    Occasional Contributor
    Hi Jean !



    I am a beginner with TC and also trying to find a working script for the above chalenge.

    Could you please give us the code here if you have modified it in order to work fine?



    Thank you very much!

    Regards