Skip to main content
March 6, 2023
Question

Dynamically setting date in Cucumber for Appian tests

  • March 6, 2023
  • 2 replies
  • 0 views

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

2 replies

paulh4005Author
April 17, 2023

Anyone have anything on this?

June 14, 2023

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.