Forum Discussion

epv's avatar
epv
Occasional Contributor
7 years ago

Checkpoint varification using varaibles and/or parameters

Hi,

 

Rookie questions!

 

In a KeywordTest i have a checkpoint that verifies a timestamp contained in a WPFControlText object. I want to replace the recorded timestamp with one in a variable (or parameter?). I have added both a project scope variable (varTimeStamp) and sat the value i want to use in the checkpoint validation.

 

I then went to the NameMapping and locate the WPF object i.e."Textblock16012018110000". In the properties window i have three-dot-option next to the recorded value "16/01/2018 11:00:00" that opens the Edit dialog. In this dialog i change the Mode from Constant to Project Variable, and in the Variable list selected my varTimeStamp. This worked as expected until I changed the value of varTimeStamp - i.e the checkpoint passes nomatter the value of varTimeStamp as the valued used in NameMapping is newer updated. So this is NOT the proper way of doing it! Should i be using a parameter instead? I have checked the documentation, but can't find the answer to this problem.

 

Appreciate any help and/or pointers.

 

Erik

 

 

 

2 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    First, you shouldn't be using NameMapping for validation.  That's a reference for the names of your objects. 

     

    For a checkpoint, you compare a property of something on the screen to a value that in this case you have stored in a variable.  If you are having trouble finding that property, then you can record a little test where you click on the object in question and you will be able to see what TestComplete thinks it is called.

     

    I'm also wondering why you would have a timestamp value in a variable to compare?  Shouldn't the value always be changing?  You don't want to have to change the variable every time you run the test.  Tell us a little more about what you are trying to do here.  There may be a simpler way to go about it.

    • epv's avatar
      epv
      Occasional Contributor

      Hi Marsha,

       

      Thanks for your reply.

       

      The overall objective of the test is to verify that rows of data is added automatically every 15 min to a GridView. Each row has a timestamp. Please see attached screenshot.

       

      When i recorded the test, i added a Property Checkpoint and clicked on the timestamt of the first row. This will replay successfully as long as the particular row i visible in the grid, even if new rows are added on the top.

       

      However, this is not what i want. I want to compare the timestamp of the top row with the system clock and verify that the timestamp is 15 min or less behind the system clock. I guess there are two approches to this:

       

      1) From the current value of the system clock, calculate what the timestamp of the top row should be, and then script wise modify the checkpoint value of the Text propery to the expected timestamp.

      The gameplan her was to save the calculate expected timestamp in a variable and then have checkpoint use this variable as its Text property value instead of the recorded value. As a step one i was manually setting the value of the expected timestamp in a varaiable, but i can't work out how to have the checkpoint use this vaiable.

       

      2) Select the top row in the GridView, read the Text value of timestamp object and compare it with a calculated expected value. For this i was using a script approach (convereted the recorded KeywordTest (click on timestamp, verify it using a checkpoint):

       

      function VA_4_Read_Timestamp()

       

      {

      //Clicks the 'ReadingsGrid' grid cell at row 0, column 'Time stamp'.

      Aliases.VisionAir_Client.HwndSource_StartupWindowView.StartupWindowView.ReadingsGrid.ClickCell(0, "Time stamp");

      //Checks whether the 'Text' property of the Aliases.VisionAir_Client.HwndSource_StartupWindowView.StartupWindowView.ActiveItemPart.GridViewRow.Textblock18012018133000 object equals '18/01/2018 13:30:00'.

      aqObject.CheckProperty(Aliases.VisionAir_Client.HwndSource_StartupWindowView.StartupWindowView.ActiveItemPart.GridViewRow.Textblock18012018133000, "Text", cmpEqual, "18/01/2018 13:30:00");

      }

       

      I can see my way though adding a vaiable, calculating the expected timestamp value (manually sat for starters) and replacing the recorded value of the checkpoint "18/01/2018 13:30:00" with the vaiable name. However the recorded timestamp is encoded in the TextBlock object name, i.e. Textblock18012018133000, and changing that name makes the checkpoint fail.

       

       

      Regards

      Erik