Dynamically setting date in Cucumber for Appian tests

Hi,

I'm using v22.4 of Cucumber for Appian and am trying to make sense of the following entry in the CheatSheet.feature file:

# Used as relative datetime for date/time fields:
Given I set start datetime
Is there a way to dynamically set the date and then use as input in dd/mm/yyyy string format? I'm struggling to find any good documentation on this.
Thanks,
Paul

  Discussion posts and replies are publicly visible

Parents
  • When you say "dynamically," do you mean a random date? If so, then yes. If you can set it to the current date, that would also be a yes. Both of these, I believe, would require you to create a custom step definition and implement some custom code.

    Random Date

    String day = randomNumber (range of 1-29)

    String month = random month (range of 1-12)

    String year = random year (range of for example 2000-2023)

    String date = randomday+"/"+randomMonth+"/"+randomyear

    Current Date

    For this, you need to look up basic Java code to get the current date and time. You have to create a formatter to format the date the way you want, then use another class that gets the current date. This gets saved to a string.

Reply
  • When you say "dynamically," do you mean a random date? If so, then yes. If you can set it to the current date, that would also be a yes. Both of these, I believe, would require you to create a custom step definition and implement some custom code.

    Random Date

    String day = randomNumber (range of 1-29)

    String month = random month (range of 1-12)

    String year = random year (range of for example 2000-2023)

    String date = randomday+"/"+randomMonth+"/"+randomyear

    Current Date

    For this, you need to look up basic Java code to get the current date and time. You have to create a formatter to format the date the way you want, then use another class that gets the current date. This gets saved to a string.

Children
No Data