Can you pause an ATF(Automated Test Framework)?

andresgt
Mega Expert

Hello Guys,

I was wondering if anyone knows how to pause an ATF between 2 steps.

I don't know if there is an OOB functionality that allows that or needs to be customized through a Server Side Validation Script.

Any idea would help.

 

Thanks!

9 REPLIES 9

The SN Nerd
Giga Sage
Giga Sage

Create Step 'Server Side > Run Server Side Script'

find_real_file.png

Insert the following code:

var waitSeconds = 10;
var waitMs = waitSeconds * 1000;

//Wait 10 seconds
gs.sleep(waitMs);

ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

By incorporating the above mentioned code in the Run Server Side Script there are few problems that I faced.

Firstly, if we add only the above mentioned 3 lines of code in the script in between 2 ATF test steps, the Server Side script is running properly, but the next step is giving an error stating "g_form is not defined" as the instance is made to sleep the test step is rolling back(which is a functionality of ATF).

 

Secondly, if we take up the previous sys_id of the test and include it in the Server side script, then the whole test step is showing an error stating the "sys_id id not undefined". This is again because of the fact that we are making the instance sleep as a result the results are rolling back and hence the sys_id cannot be fetched.

 

The only probable solution to make the ATF pause is to increase the "TIMEOUT" which will make that particular test step run for the specified amount of time.

Note: The field TIMEOUT is hidden on the form layout, but it can be modified from the list layout.

because i came here from google - i should note this isn't completely correct.

 

use `sn_atf.AutomatedTestingFramework.waitOneSecond()` instead of gs.sleep. If you need to wait more than a second, as such:

 

var waitSeconds = 10;
for(var i = 0; i < waitSeconds; i++) {
  sn_atf.AutomatedTestingFramework.waitOneSecond()
}

Soumita3
Tera Expert

By incorporating the above mentioned code in the Run Server Side Script there are few problems that I faced.

Firstly, if we add only the above mentioned 3 lines of code in the script in between 2 ATF test steps, the Server Side script is running properly, but the next step is giving an error stating "g_form is not defined" as the instance is made to sleep the test step is rolling back(which is a functionality of ATF).

 

Secondly, if we take up the previous sys_id of the test and include it in the Server side script, then the whole test step is showing an error stating the "sys_id id not undefined". This is again because of the fact that we are making the instance sleep as a result the results are rolling back and hence the sys_id cannot be fetched.

 

The only probable solution to make the ATF pause is to increase the "TIMEOUT" which will make that particular test step run for the specified amount of time.

Note: The field TIMEOUT is hidden on the form layout, but it can be modified from the list layout.