- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 12:52 AM
In one catalog item, workflow contains timer if one task is closed it takes 20 sec to create another task so I need to create the test that test should wait for 20 seconds and continue to access another task to write in the test step. Any solutions...?
Solved! Go to Solution.
- 2,516 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 01:02 AM
Hi @Anantha27 ,
Create a custom test script and add do nothing loop to wait
Refer this : https://www.servicenow.com/community/developer-forum/atf-server-script-to-wait-some-time/m-p/1879854...
Navigate to custom script step.
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 01:08 AM - edited ‎09-30-2024 02:28 AM
Here's a comprehensive approach that combines the best aspects of previous responses and addresses potential issues:
1. Identify the Relevant Task:
- Determine the exact task within the catalog item workflow that you want to wait for. This information can be found in the workflow definition.
2. Create a Test Step:
- Create a new test step in your ATF test case.
3. Set the Test Step Action:
- In the "Action" field of the test step, select "Wait for Condition."
4. Define the Condition:
In the "Condition" field, use the following expression:
JavaScriptnew GlideRecord('task').query().addQuery('state', 'closed').addQuery('sys_id', <task_sys_id>).addQuery('sys_updated_on', '<time_before_20_seconds>').query();
Replace <task_sys_id> with the actual sys_id of the task you want to wait for.
Replace <time_before_20_seconds> with a calculated time that is 20 seconds before the current time. You can use JavaScript's Date object and appropriate methods to achieve this. For example:
JavaScriptvar now = new GlideDateTime(); now.subtractSeconds(20); var timeBefore20Seconds = now.getDisplayValue();
5. Configure the Wait Time:
- In the "Timeout (in seconds)" field, set the value to a suitable timeout value. This is optional but can be helpful to prevent the test from waiting indefinitely if the condition is not met.
6. Add Subsequent Test Steps:
- After the "Wait for Condition" step, add subsequent test steps that will access the other task and perform the necessary actions.
7. Save and Run the Test Case:
- Save the test case and run it. The test will wait for 20 seconds before proceeding to the subsequent steps if the specified task is closed.
By following these steps and considering the additional factors, you should be able to create an effective ATF test that accurately simulates the waiting behavior in your catalog item workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 03:54 AM
Hi @Anantha27 ,
Here's a server-side script step in ATF that you can use to wait for 20 seconds before proceeding with the next task:
gs.sleep(20000); // 20000 milliseconds = 20 seconds & it will wait for 20 seconds
This script step leverages the gs.sleep() function to introduce a pause of 20 seconds in the ATF test execution.
Thanks,
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2024 01:22 AM
Thank you so much for the information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2024 04:15 AM
Thank you so much for the information.