- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-11-2019 05:14 AM
Hello,
I would like to use ATF for Negative tests , is it possible ?
For example, I would like to impersonate a users with role X and clarify that a specific field or button is not shown for him.
Regards,
Tomer
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-11-2019 05:54 AM
Hi,
This can be done in ATF. Do you want to hardcode the User name having a particular role and then check whether the button is visible or not then follow the below steps:
- Click on Add test Steps and then select "Impersonate" test step and select the user with whom you want to test this.
- Next step would be "Record Query" and give the details of the record you want to open.
- Next Test step would be "Open an Existing Record" and reference the record being queried in step 2.
- Next step would be UI ACtion Visibility and then refer the UI Action Name and you are done with your negative tests.
Refer the screenshots below:
In case you don't want to Hard code the User name and want to check for a dynamic User to be selected which needs to be Impersonated then you need to create a Custom Step Configurations and then Repeat the steps as mentioned above. Only Change would be the first point where selecting "Impersonate" Test step you will be selecting your custom Step Configuration and execute the same.
Below is an code on how to create Custom Step Configuration which allows you to automatically fetch a user based on your step configurations and execute your Test case:
(function executeStep(inputs, outputs, stepResult, timeout) {
var usr = new GlideRecord('sys_user_has_role');
usr.addQuery('active', true);
usr.addQuery('user.active', true);
usr.addQuery('user.locked_out', false);
usr.addQuery('role', '282bf1fac6112285017366cb5f867469'); //itil
usr.orderBy('sys_id');
usr.query();
usr.next();
outputs.u_user = usr.user+'';
stepResult.setSuccess();
}(inputs, outputs, stepResult, timeout));
Hope this help. Please mark the answer as helpful/correct based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-11-2019 05:54 AM
Hi,
This can be done in ATF. Do you want to hardcode the User name having a particular role and then check whether the button is visible or not then follow the below steps:
- Click on Add test Steps and then select "Impersonate" test step and select the user with whom you want to test this.
- Next step would be "Record Query" and give the details of the record you want to open.
- Next Test step would be "Open an Existing Record" and reference the record being queried in step 2.
- Next step would be UI ACtion Visibility and then refer the UI Action Name and you are done with your negative tests.
Refer the screenshots below:
In case you don't want to Hard code the User name and want to check for a dynamic User to be selected which needs to be Impersonated then you need to create a Custom Step Configurations and then Repeat the steps as mentioned above. Only Change would be the first point where selecting "Impersonate" Test step you will be selecting your custom Step Configuration and execute the same.
Below is an code on how to create Custom Step Configuration which allows you to automatically fetch a user based on your step configurations and execute your Test case:
(function executeStep(inputs, outputs, stepResult, timeout) {
var usr = new GlideRecord('sys_user_has_role');
usr.addQuery('active', true);
usr.addQuery('user.active', true);
usr.addQuery('user.locked_out', false);
usr.addQuery('role', '282bf1fac6112285017366cb5f867469'); //itil
usr.orderBy('sys_id');
usr.query();
usr.next();
outputs.u_user = usr.user+'';
stepResult.setSuccess();
}(inputs, outputs, stepResult, timeout));
Hope this help. Please mark the answer as helpful/correct based on impact.
Regards,
Shloke
Regards,
Shloke