ATF - Is it possible to access parameter variables in a parametized Test with a Server-Side Script Step?

Eric20
Tera Contributor

Hello SN Community,

 

    Is it possible to access to parametized variables with the Run Server Side Script Step shown below?

find_real_file.png

 

For example, I want to access these parametized variables on the server-side:

find_real_file.png

find_real_file.png

I am aware that you can access these variables with Test Step like Set Component Values (Custom UI) and others , but I need to access them on the server side. I appreciate all the help and suggestions you can provide.

 

Thank You Everyone,

Eric

1 ACCEPTED SOLUTION

Deepak Ingale1
Mega Sage

Hi,

 

Parameterised tests are not supported on Server Side

https://docs.servicenow.com/bundle/madrid-application-development/page/administer/auto-test-framewor...

 

Note: Please mark reply as correct if it has answered your question

find_real_file.png

View solution in original post

4 REPLIES 4

Deepak Ingale1
Mega Sage

Hi,

 

Parameterised tests are not supported on Server Side

https://docs.servicenow.com/bundle/madrid-application-development/page/administer/auto-test-framewor...

 

Note: Please mark reply as correct if it has answered your question

find_real_file.png

gowrisnowy
Tera Contributor
Do you find any alternate solution for this? If yes can you please post the solution it would be helpful for us.

Efrem
Kilo Contributor

You can query 'sys_atf_test_result'  by testcaseId and status to get the record(s) you need.  Some sample code you can play with below:

       //only 1 test is ever running with the unique testcaseId
       var gr = new GlideRecord('sys_atf_test_result');
       gr.addEncodedQuery('test=' + testCaseId + '^status=running');
       gr.query();

      From there, the parameters field has the data you need.

       var out = []

       if(gr.next()){

           out.push(gr.parameters);

       }

 

Good luck.

Efrem


     

Alberto Roma_ac
Kilo Contributor

Here's an alternate solution:

  1. Record Insert  (for example, an Incident)
    • Store a parameter in the description field
  2. Server-Side Script
    • Retrieve the record inserted and use the description field as the parameter
// In server-side script
//*************************
var createBufferIncident = 'a1...d7'; // sysid of previous Record Insert step
var bufferIncident = new GlideRecord('incident');
bufferIncident.get(steps(createBufferIncident).record_id);

// Use bufferIncident.description to access the stored parameter
gs.info(bufferIncident.description);

 

Hope this helps!

Alberto