Step definitions
Introduction
This page gives you an introduction into what a Step Definition is, how they are specified, as well as the list of currently supported step definitions. The intention is that you can find out all you should need to know about what are the step definitions that exist and why and how you would use them.
From the Cucumber Wiki:
A Step Definition is analogous to a method definition/function definition in any kind of OO / procedural programming language.
@When("^I logon as (.*)$")
public void logonAs(String name) throws Exception {
logonAs(name, "");
}
To use this, one would define a test step as:
Then I logon as externalUser
Please take in count that regular expressions are not supported currently in Hercules yet
Special variables
The testing framework makes available some variables that get updated when tests are run, they are:
- currentServiceCode – the business service code of the current service transaction.
- currentServiceTransactionId – the id of the current service transaction
- currentBusinessIdentifier – the business identifier of the current service transaction
- currentServiceTransactionUid – Unique Id generated for the service transaction. This variable is used via Data validations step definitions
To use the variables just call them as ${currentServiceCode} ${currentServiceTransactionId} ${currentBusinessIdentifier}
NOTE: many service transactions may be created/used when testing the registration of an entity:
- dashboard (guest user)
- logon
- dashboard (logged on user)
- registration service
- basket payment
- dashboard
- logoff
- dashboard (guest user)
- logon (internal user)
- dashboard
- task
- logoff
- dashboard
General Variables
All the following variables must be called using I (create|default) a variable called (.) with value (.) step.
For example to enter a date of birth of an individual 17 years ago must be done the following way:
And I create a variable called pastDate with value #DATEONLY_FORMATTED: 17 years ago FORMAT:dd-MMMM-yyyy#
And I enter date ${pastDate} in Date of birth
Some of the general variables to call dates, random and IDs can be found below:
- “” OR ” ” will create an empty string (From Verne stratus 20210128) For example And I create a variable called empty with value ” “
- #LONG_ID#
- #MEDIUM_ID#
- #SHORT_ID
- #TODAY#
- #NOW#
- #DAY_OF_MONTH#
- #MONTH_ABBREV#
- #YEAR#
- #MONTH#
- #MONTH_OF_YEAR#
- #MONTH_INDEX#
- #DATEONLY:yesterday#
- #DATEONLY: 10 years ago#
- #DATEONLY: 10 months ago#
- #DATEONLY:today in 1 year#
- #FORMATTED_TODAY#yyyyMMdd#FORMATTED_TODAY# : Will format today’s date into any entered format
- #USER_ID#
- #USER_ID:${variable}# – Will use the hash id of the variable
- #(dateonly)today#: Used on JSON when only supports date types only
The following variable can be used only by creating a variable only create on feature files and will not work by calling directly the variable on JSON files. Eg:
And I create a variable called today with value #DATEONLY_FORMATTED: today FORMAT:dd-MMMMM-yyyy#
- #DATEONLY_FORMATTED: x FORMAT: y#
- Where x is one of the following:
- 2 years ago
- 1 month ago
- three weeks ago
- last wednesday
- 3 days ago
- yesterday
- today
- tomorrow
- 3 days from now
- next thursday
- next week
- three weeks from now
- 1 month from now
- 1 year from now
- 2 years from now
- next month
- next year
- And y is one of the following:
- dd MMMM yyyy
- dd-MMMM-yyyy
- dd-MMM-yyyy
- dd MMM yyyy
- Where x is one of the following:
Associates
You can use associates to target labels nested under other sections on the screen and inline sections as well. The reason to use associates is to increase the coverage in terms of validations or to target multiple elements on the screen that have the same name. We do support nested associates like Personal Information > Full name > last Name
The following examples represent the same way to call a single step

And I enter text Steve in Personal Information > Full name > Last Name
And I enter text Steve in Personal Information > Last Name
Associates on tables (Available only on 20201215)
There are some scenarios where associates require identify rows to Edit. For example, on the following screenshot, we can identify 2 tables (Allocation Summary and Allocated N shares in total). To Click button Edit/Delete on Row 1 users must use
I click button Row 1 > Edit
I click button Row 1 > Delete

Different actions on Hercules
There are 3 types of steps that are cover in Step definitions:
Page actions step definitions: Relates to step definitions associated to user interactions with forms.
REST step definitions: Relates to step definitions associated to web services.
Data validation step definitions: Relates to backend data (service transactions)

