Forum Discussion

DAustermeier's avatar
DAustermeier
Occasional Contributor
8 years ago

Use wildcards in If...Then statement

Hi there, I want to do check if an object property is beginning with "0 MIL". If it does I'd like to do some operations and if it doesn't I'd like to do sth. else. Therefore I tried to use a wi...
  • tristaanogre's avatar
    8 years ago

    What you could do in your keyword test is, before your If... then, do a "Call Object Method" on aqObject.  Select the method "CompareProperty" (https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqobject/compareproperty.html).  In the first parameter, select Object property and pass in the property that you want to check.  In the second parameter, enter the integer 8 (for "cmpStartsWith").  Third parameter, set to your 0 MIL you're looking for.  Fourth parameter set to boolean "true" for case sentitivity.  Fifth parameter set to 0 so no message is posted to the log.

     

    Now, in your If... then, you use "Last Operation Result" for the first half of the if... then and use "true" for the second half.  The result of all this is that your keyword test will first run the method to see if your property string starts with the characters 0 MIL.  It will return either true or false.  If it returns true, your If... then logic will trigger the condition and execute your conditional block.