The ‘GenerateItem’ action is designed to create dynamic ‘items’ to use elsewhere in a script. Unlike the PickItem action which selects from a predefined list, this action is used for creating things dynamically such as randomised email addresses, passwords or dates.
Often in user registration journeys, we need to create unique email addresses so as not to always use the same one and therefore be rejected by the target website’s validation. We recommend using a ‘consistently unique’ email format for this so you can easily search for and delete accounts registered using the defined format. The idea is that part of the email addresses used is consistent (i.e always start with “rapidtest”) and part is randomised so every address is unique.
To achieve this you would enter this in the Format attribute; “firstname.lastname@example.org”, and this in the Parts attribute; “%random_string%”.
The “%s” in the Format will be replaced by the “%random_string%” part, which in turn generates a random set of characters. The final email addresses could look something like these:
In order to generate an email address, select the ‘Email’ item type when adding the GenerateItem action.
Similar to the PickItem action, all GenerateItem actions must be given a ‘Name’ attribute – this is where the generated item will be placed in the
$ScriptVariable namespace to be accessed via dot notation.
Next, define your ‘Format’ and ‘Parts’ attributes (multiple parts must be separated by commas). You may use as many “%s” as you wish – they will be replaced in sequence by the Parts list.
This example will generate an email address such as “test+2aS11vBz@example.com” into the
$ScriptVariable.emailaddress location, where “2aS11vBz” is random each time an email address is generated:
If you wish to increase the randomisation you can add the random string twice. Just add an extra “%s” to the Format and then a second “%random_string%” to the Parts (comma separated).
- Format: email@example.com
- Parts: %random_string%,%random_string%
To use the generated item, enter
<Name> is the name you gave when setting up the action.
The generated string can be input into a text field using either a SendKeys, Form or FormSelector action, dynamically placed in the URL used in an Open action, or in the body of an ApiCall action. Here is an example of it being used in a SendKeys action: