ATF - FAILURE: g_form is not defined. A valid form must have g_form defined

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 11:36 PM
Have anybody found a solution for this error
FAILURE: g_form is not defined. A valid form must have g_form defined
I am getting this error in the test step "Open a Form (SP)". I open a custom portal with a custom page that contains 3 custom widgets.
I have tried to setup g_form with code like this
$scope.$on('spModel.gForm.initialized', function (e, gFormInstance) {
g_form = gFormInstance;
}
but the event spModel.gForm.initialized is never fired.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 08:18 AM
Unable to open the link shared. Still same issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 01:41 AM
The message "FAILURE: g_form is not defined. A valid form must have g_form defined" will be displayed if the form isn't be opened during 60 sec. You don't need to add any code, which sets g_form. I'd recommend you to examine the screenshot, added as attachment to the test results. I guess that the input parameters of the test step "Open a Form (SP)", which you use, is wrong. If you would use for example wrong sys_id parameter for example, then you will get exactly the same error and you will see the text "Record not found" on the screenshot instead of the form, which you try to open.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 02:01 AM
That is not the issue. The form is opened fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 02:50 AM
In the case you should describe more detailed the custom widgets existing on custom page, which you opens.
The test step "Open a Form (SP)" is oriented on a page, which contains a form, which set global property (global variable) g_form on window object. The test step "Open a Form (SP)" opens specified portal page and test every 2 sec during 60 sec whether g_form exists. It uses the existence of g_form as criteria that the page is successfully opened. If no widget from the 3 custom widgets on your page creates GlideForm then you will be not able to use test step "Open a Form (SP)".
The test step "Open a Form (SP)" uses the following code:
...
function passStep() {
g_ui_testing_util.setTestStepStatusMessage(MESSAGE_KEY_SUCCESSFULY_OPENED);
stepResult.success = true;
stepResult.message = MESSAGE_KEY_SUCCESSFULY_OPENED;
step.defer.resolve();
}
function failStep(msg) {
var message = msg || MESSAGE_KEY_FAILED_TO_OPEN;
g_ui_testing_util.setTestStepStatusMessage(message);
stepResult.success = false;
stepResult.message = message;
step.defer.reject();
}
function ensureGform() {
if (gFormCheckCount === 10) {
return failStep(MESSAGE_KEY_FAILED_NO_G_FORM);
}
gFormCheckCount++;
if (g_ui_testing_util.getTestIFrameWindow().g_form) {
return passStep();
}
window.setTimeout(ensureGform, 2000);
}
g_ui_testing_util.setTestStepStatusMessage(MESSAGE_KEY_OPENING);
var portal = step.inputs.portal;
var page = step.inputs.page;
var query_params = JSON.parse(step.inputs.query_params || '{}');
query_params.table = step.inputs.table;
var wait_timeout = step.inputs.wait_timeout;
query_params.sys_id = (step.inputs.param_sys_id) ? step.inputs.param_sys_id : - 1;
if (step.inputs.param_view) {
query_params.view = step.inputs.param_view;
}
g_ui_testing_util.openPortalPage(portal.url_suffix, page.id, query_params, wait_timeout)
.then(ensureGform, failStep);
};
You can see that g_ui_testing_util.openPortalPage is the main step, which uses ensureGform function to validate the opened page. You can clone (copy) the code of "Open a Form (SP)" (found in Automated Test Framework > Administration > Step Configurations). In any way you should decide, which criteria can be used to verify that your custom page with all custom widgets is successfully opened. You can test the criteria in you modified version of ensureGform.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 03:24 AM
The widget contains nothing more than a this
<div>
<h1>test</h1>
</div>
and no server code and no client controller code.
So basically I need to make my own test steps to get this to work. Thanks.