Can attachment functionality be tested with the ATF?

RJordan
Kilo Contributor

I want to create a test that checks if attachments are successfully being added and submitted with an incident using ATF? Is there a test step for adding attachments or can it not be tested automatically? Thanks in advance.

1 ACCEPTED SOLUTION

mishu1
Tera Guru

Hi Jordan,

The test step to validate the functionality for adding attachments cannot be tested via Automated test framework application using form side validation, however it may be possible via server side validation (Jasmine scripting).

 

Regards,

Mishu

 

Note: Please mark this response as "Helpful", if in case it has resolved your query. 

 

View solution in original post

11 REPLIES 11

mishu1
Tera Guru

Hi Jordan,

The test step to validate the functionality for adding attachments cannot be tested via Automated test framework application using form side validation, however it may be possible via server side validation (Jasmine scripting).

 

Regards,

Mishu

 

Note: Please mark this response as "Helpful", if in case it has resolved your query. 

 

John william
Kilo Contributor

Hi Mishu,

 

Can you provide me with an example script i can use to achieve adding an attachment via server side script. 

Thanks in adavance,

 

Thanks & Regards,

Karthikeya

srinivasthelu
Tera Guru

Create a New Step configuration. 

 

Step Environment : UI (There is a soft limitation) from the UI but.. 

 

 

(function executeStep(step, stepResult) {

var MESSAGE_KEY_UNABLE_TO_ADD_ATTACHMENTS = "FAILURE: Unable to add attachments";
var MESSAGE_KEY_FAILED_NO_G_FORM = "FAILURE: Unable to set values, g_form is not defined. A valid form must be open before setting values";
var MESSAGE_KEY_SUCCESSFULL = "SUCCESS:Successfully added attachments";

function passStep() {
stepResult.message = MESSAGE_KEY_SUCCESSFULL;
stepResult.success = true;
step.defer.resolve();
}

function failStep(reason) {
stepResult.message = reason;
stepResult.success = false;
step.defer.reject();
}


var testFrameWindow = g_ui_testing_util.getTestIFrameWindow();
if (!testFrameWindow.g_form) {
failStep(MESSAGE_KEY_FAILED_NO_G_FORM);
return;
}


var scope = testFrameWindow.angular.element("#sc_cat_item").scope();

var ga = new GlideAjax('Util');
ga.addParam('sysparm_name', 'copyAttachments');
ga.addParam('step_id', step.sys_id);
ga.addParam('item_id', scope.data._generatedItemGUID);
ga.getXMLWait();

var answer = ga.getAnswer();
testFrameWindow.alert(answer);
scope.attachments= JSON.parse(answer);

scope.setFocusToAttachment();
scope.$apply();


passStep();

}(step, stepResult));

 

Client Callabale Script Include : 

 

var Util = Class.create();
Util.prototype = Object.extendsObject(AbstractAjaxProcessor, {

copyAttachments: function (){
var step_id = this.getParameter('step_id');
var payroll_id = this.getParameter('item_id');
var answer = [];
GlideSysAttachment.copy('x_uxck3_payroll_request', payroll_id, 'sys_atf_step', step_id);

var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name', 'sys_atf_step');
gr.addQuery('table_sys_id', step_id);
gr.query();
while(gr.next()){
answer.push({
'file_name' : gr.file_name+'',
'sys_id' : gr.sys_id+''

});
}
return JSON.stringify(answer);

},

type: 'Util'
});

Hi Srinivas,

Will this help for record producer as well?

I have record producer which requires attachment before submission

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader