Forum Discussion

AndrewCast's avatar
AndrewCast
Contributor
7 years ago

Unable to add the image. Cannot save an empty image

I've been using this code below to compare regions before and after an action:

 

Regions.AddPicture(Sys.Desktop.ActiveWindow(), "preCommand")
#Does some stuff
postCommand = Sys.Desktop.ActiveWindow()
if (not Regions.Compare("preCommand", postCommand)):
#Does some stuff

 

It used to work fine but suddenly it's giving me an error "Unable to add the image. Cannot save an empty image."

I should mention that this is run on a loop - it stopped someway through and then trying to restart the loop won't let me run a single comparison. Any advice?

 

Thank you!

  • Are you saying that you can't run it at all now?  Or can you still start the test over and it will fail after some number of loops?

     

    If it won't run at all, I would reboot the machine this is running on and before you start TestComplete and your app under test, make sure there are as few other apps running as possible.

     

    If it will run a little, put a break point at the top of the loop and run it in debug.  Slowing it down this way may help you see what's going off.

  • Are you saying that you can't run it at all now?  Or can you still start the test over and it will fail after some number of loops?

     

    If it won't run at all, I would reboot the machine this is running on and before you start TestComplete and your app under test, make sure there are as few other apps running as possible.

     

    If it will run a little, put a break point at the top of the loop and run it in debug.  Slowing it down this way may help you see what's going off.

    • AndrewCast's avatar
      AndrewCast
      Contributor

      Hi Marsha!

       

      That was it, thank you! It wouldn't run at all, restarting the computer fixed everything but I didn't expect that.

       

      So the issue is that there were other windows that overlapped or something like that? I tend to run this for hours on end so does this mean I'll have to restart windows every once in a while?

       

      Thank you :)

      • Marsha_R's avatar
        Marsha_R
        Moderator

         

        Yay!  Glad you got going again.

         

        It could be a few things. 

         

        Might be overlapping windows - try and clean up everything at the end of one loop of the test - close browsers, apps, whatever, so you always start up clean.

         

        Could also be a memory issue.  TC is a memory hog and if you have other things running on the same machine like Excel or Word or extra Chrome instances, make sure those extra things are all closed when you test.  If it still happens, you might look at your app under test and see if there's a memory leak.