ATF tips: Time inputs for calendar fields and wait times

If you’re using the Automated Test Framework in ServiceNow, our team has identified some helpful scripts and step setups to accommodate automatic adjustments to date fields and wait times.

 

  1. Type of Script/Step Setup: Automatically adjusts date fields on any form.

This can be used to set the Planed Start Date and Planned End Date each time so you don’t have to update the fields before each run. A use case for this scenario is during ATF setup for a Change Workflow process where the date fields are required to hit a certain time before processing the workflow. (The times show in the scripts are set based on the timezone within the ServiceNow instance).

 

Planned start date: javascript:gs.minutesAgo(-3);
Planned end date: javascript:gs.daysAgo(-2);

 

This screenshot from ATF shows how the script populates the fields:

 

  1. Type of Script/Step Setup: Adding a wait time to pause the next action until a specified amount of time has elapsed.

This can be used to allow for time to pass automatically before triggering the next step in a process. For example, if you needed to insert a wait time for the ATF to wait until a specified time in order for a Change workflow to generate correctly.

For example, when processing a Change workflow, there may be a requirement to wait until the Planned Start date hits a specific time in order for the workflow to kickoff.

A use case for this scenario is setting the Planned Start time to 5 minutes in the future on a Change record. Following the below steps forces the ATF to wait until the Planned Start hits, then it will continue with testing the workflow.

Wait step:

 

·        Open Existing Record
·        Field Values Validation
·        Planned start date before Current Minute
·        Timeout – 200 seconds (this can be adjusted as needed)

 

Example of the step setup within ATF:

Contact Us