Forum Discussion

jope's avatar
jope
New Contributor
13 years ago

How can I avoid setting af breakpoint?

Hi


I have a problem when comparing 2 pictures (screenshots). It works as expected when I use a breakpoint and continue test execution immediately but fails when I remove the breakpoint. Adding a delay instead of the breakpoint does not solve the problem.


I am testing some undo (similar to MS Office Ctrl-z) and redo (similar to MS Office Ctrl-y) functionality.


I use the following (pseudo)code: 


Set L_ObjPicture_A=MyOwnName.Picture()


L_ObjPicture_A.SaveToFile("c:\Data\A.bmp")


Then I do some changes and a corresponding numbers of undo and redo.


Now I have the same screen as when I started.


Set L_ObjPicture_B=MyOwnName.Picture()


L_ObjPicture_B.SaveToFile("c:\Data\B.bmp")


The A and B files are different when I run the whole script, but equal if I set a breakpoint at the line with Set L_ObjPicture_B=MyOwnName.Picture() and then immediately continue running the script.


Excluding the mouse cursor makes no difference and a delay of several seconds before the line with Set L_ObjPicture_B=MyOwnName.Picture() does not solve the problem.


Do you have any ideas what I can do instead of setting a breakpoint?


Best regards


Johnny Pedersen

5 Replies

  • jope's avatar
    jope
    New Contributor
    Hi



    I attach the two different bitmap files. When I run my script with a breakpoint the resulting files are equal.



    BR



    Johnny

  • Hi Johnny,



    There are slight differences between the two images - possibly caused by gradients or smoothing. Setting the PixelTolerance and the ColorTolerance parameters of the Region checkpoint to 4 will make TestComplete treat them as equal: 




    var img2 = Utils.Picture; 

    img2.LoadFromFile("d:\\DELETE ME\\A\\AA.bmp"); 

    Regions.A_bmp.Check(img2, false, false, 4, 4); 



    In the future, I recommend that you follow the suggestion provided in the Why Image Comparison Fails help topic if you face such problems again.
  • jope's avatar
    jope
    New Contributor
    Hi Allen



    Thanks for your advice.



    BR Johnny