ATF test step

Anantha27
Mega Guru

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...?

3 ACCEPTED SOLUTIONS

Hemanth M1
Giga Sage
Giga Sage

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.

HemanthM1_0-1727683295651.png

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

Sai Krishna6147
Mega Guru

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:

    JavaScript
    new 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:

      JavaScript
      var 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.

View solution in original post

Ramesh_143
Giga Guru

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

View solution in original post

6 REPLIES 6

hazeljames3
Kilo Contributor

Thank you so much for the information.

JuanitaC
Giga Contributor

Thank you so much for the information.

https://academized.com/buy-argumentative-essay academized. The process was easy, and the quality of the essay exceeded my expectations. The writer presented clear and logical arguments, supported by reliable sources.