The CreatorCon Call for Content is officially open! Get started here.

Custom Test Step in ServiceNow ATF (Automated Test Framework)

Abhishek_Thakur
Mega Sage

A custom test step in ServiceNow’s Automated Test Framework (ATF) is a reusable test action you can build when out-of-the-box (OOTB) test steps are not sufficient for your use case. It allows developers to design their own logic, validations, or UI interactions tailored to specific business requirements.

🔹 Benefits of Custom Test Steps:
Extend ATF beyond OOTB capabilities
Handle complex test logic and scenarios
Promote reusability by creating steps once and using them across multiple test cases

You can also refer the below link for the implementation video of ServiceNow custom test step in ATF

https://youtu.be/IzCuPibHXfg?si=GdFPFtLghSqUAtyp

1 REPLY 1

sreeram_nair
Tera Guru

@Abhishek_Thakur Well Explained. Just adding an example below.
For Server Test Steps
(common case):

  • In the Script field, write a GlideScript block that sets a result variable.

  • Return an object with success and message keys.

(function stepAction(inputs, outputs, stepResult) {
    // Retrieve record
    var rec = new GlideRecord('x_custom_table');
    if (rec.get(inputs.record_sys_id)) {
        if (rec.u_custom_field == inputs.expected_value) {
            stepResult.setOutputMessage('Validation passed');
            stepResult.setSuccess();
        } else {
            stepResult.setOutputMessage('Expected ' + inputs.expected_value +
                                        ' but found ' + rec.u_custom_field);
            stepResult.setFailed();
        }
    } else {
        stepResult.setOutputMessage('Record not found');
        stepResult.setFailed();
    }
})(inputs, outputs, stepResult);

For Client Steps (browser actions), you’d use a client-side script and the g_form, g_scratchpad, or DOM APIs.


ɪꜰ ᴍʏ ᴀɴꜱᴡᴇʀ ʜᴀꜱ ʜᴇʟᴘᴇᴅ ᴡɪᴛʜ ʏᴏᴜʀ Qᴜᴇꜱᴛɪᴏɴ, ᴘʟᴇᴀꜱᴇ ᴍᴀʀᴋ ᴍʏ ᴀɴꜱᴡᴇʀ ᴀꜱ ᴛʜᴇ ᴀᴄᴄᴇᴘᴛᴇᴅ ꜱᴏʟᴜᴛɪᴏɴ ᴀɴᴅ ɢɪᴠᴇ ᴀ ᴛʜᴜᴍʙꜱ ᴜᴘ.




ʙᴇꜱᴛ ʀᴇɢᴀʀᴅꜱ


ꜱʀᴇᴇʀᴀᴍ