ATF

Nag9
Tera Expert

How to create ATF test in servicenow

7 REPLIES 7

Harsh Vardhan
Giga Patron

adding few blogs link, please refer that. hope it will help you. 

 

Automated Test Framework Part 1: First Impression

 

Best practices for using ATF

Create ATF test to implement below steps:
Verify below pages on mobile url (https://xxxx.service-now.com/$m.do#/home):
1. Favorites
2. Field Service
3. Home Page

Note: If suitable steps are not found in ATF, need to be created using step "Run Server side script"

 

 

Can you please guide me how to this with proper screen shots

 

Im new to ATF 

Snehal Pawar
Tera Expert

Hi,

You can refer below url:

https://docs.servicenow.com/bundle/london-application-development/page/administer/auto-test-framework/task/atf-enable-tests.html

 

Mark it correct or helpful, If it helps you.

 

 

Thanks,

Snehal.

Akash4
Kilo Sage
Kilo Sage

Hi Nag,

I found a way to verify your requirement - taking an example for Homepages in mobile view. You can use this as sample case and solve your all requirements. I have only used True or Success Case here, you can define failure cases as well.

For Assertion (which is used for checking the expected and actual values) you can use this function:

var testAssertion = {
name: "my test assertion",
shouldbe: "expected value"
value: "actual value",
};
assertEqual(testAssertion);

You can follow these screenshots for a quick view, code snippet is also provided for easy reference.

1. Test in ATF

find_real_file.png

2. Test Step - Run Server Side Script

find_real_file.png

3. Code snippet

(function(outputs, steps, stepResult, assertEqual) {
	// add test script here
	var list = ['My Incidents','Knowledge','Location','My Requests','Service Catalog','My Approvals','Favorite KPIs','Connect'];
	var gr2 = new GlideRecord('sys_ui_mobile_home_page_section');
	gr2.query();
	while (gr2.next()){
		var gr = new GlideRecord('sys_ui_mobile_home_page_module');
		gr.query();
		while (gr.next()){
			stepResult.setOutputMessage("The module found in Homepage is"+gr.title);
			gs.log('Found 1 module'+gr.title);
			for (i=0;i++;i<(list.length)-1){
				assertEqual({name: "Checking Module Name", shouldbe: list[i], value: gr.isValidRecord()});
				}}// pass the step
				
				return true;
			}
			
			
		})(outputs, steps, stepResult, assertEqual);
		// uncomment the next line to execute this script as a jasmine test
		//jasmine.getEnv().execute();

 

Output:

find_real_file.png

Thank you. If you find this answer as helpful or correct, please mark it so!

Regards, Akash

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.