Creating parameters for the username and password

You can create parameters that are used for the username and password in a script. When the script is run, the parameters are replaced with values stored in the test on the Dynatrace Portal.

Parameters can be used for values that change periodically. Insert the parameter code into the script and specify the parameter values in the test's Advanced Settings in the platform.

In the script, locate the step where authentication occurs, typically the first or second step.

Add a Custom action to this step. The Custom action Custom action performs the task of dynamically construction a payload or a header value.

The Custom action must appear before the HTTP action in the timeline.

Specify control as the name of the Target Window.

In the Code field, add the code for the request whose body is assigned at runtime.

var username = parameters['username'];
var password = parameters['password'];
var postString = 'poststring_username=' + username + 'poststring_password=' + password;
parameters.tokenRequest = postString;
postStringB64 = window.btoa(postString);
script.steps[0].actions[1].requestList[0].body = postStringB64;

Adding a Custom action

Test the script and upload it to the Dynatrace Portal.

In the platform, create a test to run the script.

After you have created and saved the test, edit the test by selecting it from the list on the Tests page.

In the test, select the Advanced Settings tab and specify the values for the username and password variables, as shown in the following example:

In addition to the username and password, you can also create and use parameters to replace any other value that may change in the script.

When the script runs on the agents, it uses the parameter values that you specified in the test's Advanced Settings.