Forum Discussion

AndrewCast's avatar
AndrewCast
Contributor
6 years ago
Solved

Checking if anything has changed after a script line

Hi everyone,

 

I'm testing a graphic extensive application, and I'm using Python to script all of my test cases.

 

Let's say I have to run a command X that would result in a small window attaching itself to the right of the screen.

Is there a way for me to run something wherein I save a picture before this command, and save a picture after this command - then compare a region of it (as perhaps the time changed or the statusbar text) to see if that action triggered a reaction.

 

Does it have to do with this: https://support.smartbear.com/testcomplete/docs/testing-with/visualizer/about.html

 

Is something like this possible? If not, what's your workaround? 

 

Thank you!

  • Sure... Check out the Regions object and related methods

     

    https://support.smartbear.com/testcomplete/docs/reference/project-objects/items/stores/regions/methods.html

     

    Basically, you're going to call Regions.Add to add the "before" picture.  Then, use Regions.Compare to compare the stored image with the real-time image from the application.

     

    Now... my druthers... I don't like using regions to do stuff because they are so dependent upon pixel depth, screen resolution, minor positioning, fonts, etc....  All SORTS of things that could cause a false difference to show up.  My suggestion would be to check for existance... I'm assuming that the small window didn't exist before the command... rather than taking, what is effectively, as screenshot and comparing it, I'd actually check to see if the new window is present and, if so, if it's Top and Left properties are within an expected range for it to be on the right side of the screen... perhaps check the TOTAL screen resolution and then make sure the LEFT property is the left side of the screen minus the Window width... or maybe there is some property on the window that indicates "Docked" or something like that...  All sorts of ways of checking the presence and location of an object without having to do screen image comparisons.

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Sure... Check out the Regions object and related methods

     

    https://support.smartbear.com/testcomplete/docs/reference/project-objects/items/stores/regions/methods.html

     

    Basically, you're going to call Regions.Add to add the "before" picture.  Then, use Regions.Compare to compare the stored image with the real-time image from the application.

     

    Now... my druthers... I don't like using regions to do stuff because they are so dependent upon pixel depth, screen resolution, minor positioning, fonts, etc....  All SORTS of things that could cause a false difference to show up.  My suggestion would be to check for existance... I'm assuming that the small window didn't exist before the command... rather than taking, what is effectively, as screenshot and comparing it, I'd actually check to see if the new window is present and, if so, if it's Top and Left properties are within an expected range for it to be on the right side of the screen... perhaps check the TOTAL screen resolution and then make sure the LEFT property is the left side of the screen minus the Window width... or maybe there is some property on the window that indicates "Docked" or something like that...  All sorts of ways of checking the presence and location of an object without having to do screen image comparisons.

    • AndrewCast's avatar
      AndrewCast
      Contributor

      Hi Robert, thank you for your reply! 

       

      While I do agree that chances are, with screenshots, a lot of the tests are going to fail as the UI will change over time - but this is a heavily graphical software that I'm automating, and sometimes what I need to check is simply if the cursor changed or a tooltip appeared.

       

      For now, I think comparing screenshots is the best way to checking if anything happened. I might switch to something else in the future, and hope to.

       

      Thank you again for your help :)