Forum Discussion

tristaanogre's avatar
tristaanogre
Esteemed Contributor
8 years ago

Pro-Tip: Parameterized Object Property Checkpoints in Keyword Tests

There are, perhaps, some of you who may have already discovered this.  I'm a script coder and prefer to write code for my tests so I'm working on learning the ins and outs of using Keyword Tests more these days.  In doing so, I ran into a problem... and a rather cool solution.  It's not huge, but it might help some of y'all.

 

Problem:

When writing keyword tests, if you want to add a checkpoint on an Object Property, there is a limitation.  It happens on this screen:

 

 

What I have highlighted in red will only take a direct string value.  You cannot call a Code Expression, a variable, a test parameter, or anything else "cool" in here... only a string.  If you're like me, your test cases can be used in multiple situations with perhaps data that will vary from run to run.  So, there is a need for doing the check comparing the property to some data coming from another source.  At first, I thought that the only recourse was to do an If-Then statement to do the comparison of an object property to a variable/parameter.  This worked... but it looked clunky and didn't feel right.

 

Solution:

Then I realized that the Call Object Method operation can be used to call the method of ANYTHING that TestComplete recognizes as an object, including the aqObject object... which happens to have a CheckProperty method.  So, instead of my if-then, I add a Call Object Method operation and, in the object field, I enter simply aqObject. When I click next, I now have the CheckProperty method available.  I select that, and now I can fill in the fields using whatever values I want, including parameters, variables, code expressions, etc.

 

SPECIFICALLY, I can now parameterize the Value field, something I couldn't do with just a Object Property Checkpoint.

 

 

The end result is that, when I run this, in my test log, it treats it just like an Object Property Checkpoint operation complete with Checkpoint event on a pass.

Again... just discovered this recently myself, but thought I'd share.  You can, obviously, do this same thing with any number of other native objects in TestComplete in keyword tests, opening up a lot more possibilities to those of us who may not be coders.

2 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    Hi,

     

    Nice solution.

     

    Also we have another way:

     

    1. After you have created your checkpoint click on it under Value column.

     

     

    2. This will open "Operation Parameters" dialog. Click on the ellipsis button:

     

     

     3. This will open "Edit parameter" dialog:

     

     

     

     Here you can setup the value using variable, code expression etc.

     

    However I am very surprised why TestComplete does not allow to setup it during initial wizard.

     

     

     

     

     

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Hrm... Well... for some reason, that wasn't working for me.  And look at that, just tried it, it works.  I feel sheepish. :)

      Thanks, baxatob. :)

      Either way, though, I agree... the property checkpoint wizard could stand to have this same capability.