[Help] Attachment testing ATF

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 03:26 AM
Hello,
I'm currently using the ATF module to test my incident forms and I would like to test the "manage attachments" area.
However, when I go to add a test step I can't to find the option which allows me to do this.
Any ideas?
Here's a screenshot of the "manage attachments" tab:
Kind Regards,
Jordan
- Labels:
-
Automated Test Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 06:54 AM
Hi Jordan,
I don't believe the ATF currently supports testing adding an attachment so you wouldn't find it in the test form steps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 07:05 AM
Thought so,
Guess they can include that in London .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2019 08:26 AM
You can test adding attachments. You just need to have steps for inserting the Parent attachment record into the sys_attachment table, and the Child attachment byte data records into the sys_attachment_doc table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 11:19 PM
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'
});