Forum Discussion

Chi's avatar
Chi
Occasional Contributor
7 years ago
Solved

Checking Region images without automatically having Checkpoint ticks and crosses in test log

My aim is to re-implement the following image check method into one that doesn't automatically post a Tick or Cross to the Test Log when Check passes or fails:

 

 

def original_image_check(self, icon=None):
   if icon is None:
      icon = self.frmMain.frmStatusBar.pnlPIFs.framePIF_right
   Regions.imgCoilCon.Check(icon.imgCoil)

My new method which returns True or False is as follows:

 

 

def new_image_check(self, icon=None):
   if icon is None:
      icon = self.frmMain.frmStatusBar.pnlPIFs.framePIF_right
   if not Regions.Compare(Regions.imgCoilCon, icon.imgCoil, False, False, True, 0, lmMessage):
      return False
   return True

But when I run the test, I get two "Cannot get a picture object from the input parameter." errors. I assume it's one error each for the first 2 parameters of the Regions.Compare() call.

 

What am I doing wrong?

 

Regions.imgCoilCon is an image that is stored in my Regions collection.

icon.imgCoil is a VCL Object that contains the image on the application I am testing

  • I'm assuming there is actually a child object called "imgCoil" on icon?  You might want to double check that.  That's part of the problem.  Depending upon the timing of things, that object may not exist when you call your code.

     

    As for the other half, you need to change your code to the following:

    def new_image_check(self, icon=None):
       if icon is None:
          icon = self.frmMain.frmStatusBar.pnlPIFs.framePIF_right
       if not Regions.Compare("imgCoilCon", icon.imgCoil, False, False, True, 0, lmMessage):
          return False
       return True

    If you're going to use an item in your Regions collection, the parameter for that is a string that is the name of the Regions object that you want to use.

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I'm assuming there is actually a child object called "imgCoil" on icon?  You might want to double check that.  That's part of the problem.  Depending upon the timing of things, that object may not exist when you call your code.

     

    As for the other half, you need to change your code to the following:

    def new_image_check(self, icon=None):
       if icon is None:
          icon = self.frmMain.frmStatusBar.pnlPIFs.framePIF_right
       if not Regions.Compare("imgCoilCon", icon.imgCoil, False, False, True, 0, lmMessage):
          return False
       return True

    If you're going to use an item in your Regions collection, the parameter for that is a string that is the name of the Regions object that you want to use.

    • Chi's avatar
      Chi
      Occasional Contributor

      Hi Robert,

       

      Thanks for your reply, your suggested change worked!