Forum Discussion

jyothinb's avatar
jyothinb
Contributor
10 years ago

How to create a property checkpoint for hard code value & a variable

Hi, I am trying to create a property checkpoint for a 'WndCaption' property. Value should always match to "Last Visit 9/10/2015 (0 days ago)". Here date value may change and even the number 0 may change depending on the test case. I have tried using wild characters like "Last Visit * (* days ago)". But it's not working. Any suggestion please. Also is there anyway I can make sure date is today's date? I am using keyword testing. Any help is appreciated. Thanks.

  • the string you want to use as a baseline will look something like this:

     

    "Last Visit " + aqDateTime.Today() + " (" + myvariablefornumberofdays + " days ago)"

     

    Instead of using a Property Checkpoint, build your own with an If Then.  See attached screenshot.

     

     

  • What Marsha_R said, but with two notes:

     

    1) You may need to format the date using aqConvert.DateTimeToStr or aqConvert.DateTimeToFormatStr.


    2) No need for If...Then -- you can use variables in checkpoints directly. First, create a checkpoint with the hard-coded value first. Then click the checkpoint's Value string, press F2 and replace the hard-coded value with a variable.

     

    property-checkpoint-with-variable.png

  • the string you want to use as a baseline will look something like this:

     

    "Last Visit " + aqDateTime.Today() + " (" + myvariablefornumberofdays + " days ago)"

     

    Instead of using a Property Checkpoint, build your own with an If Then.  See attached screenshot.

     

     

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    What Marsha_R said, but with two notes:

     

    1) You may need to format the date using aqConvert.DateTimeToStr or aqConvert.DateTimeToFormatStr.


    2) No need for If...Then -- you can use variables in checkpoints directly. First, create a checkpoint with the hard-coded value first. Then click the checkpoint's Value string, press F2 and replace the hard-coded value with a variable.

     

    property-checkpoint-with-variable.png

    • Marsha_R's avatar
      Marsha_R
      Moderator

      We got away from using Property Checkpoints because they slowed our tests down considerably.  If Then runs a lot quicker even if it has more code than just an log message.

      • jyothinb's avatar
        jyothinb
        Contributor

         

        Thanks Helen Kosova and Marsha for your help,

         

        There is one more issue with month, I am using below code

         

        "Last Visit "+ aqConvert.DateTimeToFormatStr(aqDateTime.Today(),"%m/%d/%Y") +" (0 days ago)"

         

        I am getting expected value of month as "09" but it should be only "9"

        Actual value "Last Visit 9/16/2015 (0 days ago)"
        Expected value "Last Visit 09/16/2015 (0 days ago)"

         

        what type of format I should use?