cancel
Showing results for 
Search instead for 
Did you mean: 

Checking if anything has changed after a script line

SOLVED
Highlighted
Contributor

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Checking if anything has changed after a script line

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

 

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

 

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

2 REPLIES 2
Highlighted
Community Hero

Re: Checking if anything has changed after a script line

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

 

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

 

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

Highlighted
Contributor

Re: Checking if anything has changed after a script line

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 🙂

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors