Forum Discussion

heidi_n's avatar
heidi_n
Regular Contributor
9 years ago

How to create a Checkpoint for a Date that is always changing?

Hi,

 

How can I create a checkpoint for a date that is always changing?

 

Example:

Order is placed today 2/4/16 we need to ship 2/6/16. Verify ship date is 2/6/16

But if "today = 2/10/16" when we run the test on 2/10, the ship date is 2/12/16. Verify ship date is 2/12/16.

So I want it to look at today's date (always changing depending on what day we run the test) and verify the ship date is always 2 days out.

 

Note: I only know how to use Keyword tests and don't know how to code.

 

Thanks,

 

Heidi

4 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    You can use a code expression in your propertcheckpoint and use aqDateTime.AddDays

  • djadhav's avatar
    djadhav
    Regular Contributor

    What is the language set for your project? VBScript, JScript or other

    • heidi_n's avatar
      heidi_n
      Regular Contributor

      We always choose Delphi for Scripting Language because our program is written in Delphi & SQL, but I don't know how to code.

      • Soren's avatar
        Soren
        Occasional Contributor

        Hi Heidi,

         

        I am much like you, I  don't know a lot of a javascript or Delphiscript, but you can get around that. There is the is an operation in the keywordtesting thats called " Run Code Snippet".  You can used that to get dates, compare them, do some calculation with dates. 

         

        We use Javascript, but as fare as I can read from this article: https://support.smartbear.com/viewarticle/68129/#Basics you can used the same methods as well.

         

        this works for me - there might be a better way around it ;-)

         

        1. Add a "Run Code Snippet" to your test.
        2. click on " Select Object" and choose the aqDateTime runtime Object
        3. In the small dialog box add .Today() - yo will see that an helpfunction called Intellisense is trying to help you - so the dialog box ends up containing aqDateTime.Today()
        4.  Click OK
        5. now add a "Set variable Value" - add a local variable to your test - leave it as a string and give it a meaningfull name
        6. Now to give the variable a value change the "Mode" from Constant to Last Operation Result 
        7. Add another "Run Code Snippet" to your keywordtest and click on " Select Object" and choose the aqDateTime runtime Object
        8. This time type in .AddDays() - in between the brackets add the following: KeywordTests.[here-should-be-the-name-of-your-testcase].Variables.[The-name-of-your-variable] then a comma and then the number of days you want to add to the date. to give you an example of how it could look like : aqDateTime.AddDays(KeywordTests.Test1.Variables.Tdt, 2)

        I hope this helps.

         

        Kind Regards

         

        Soren