Information:

Environment

  • Dynatrace Recorder

 

 

 

Solution

Add headers to a script

This procedure will apply the headers value across the whole script:

  1. Open a script.
  2. Click the Script button to the left of the action timeline.
  3. Select the Headers tab.
  4. Click the add button ( + ) located to the right of the Headers box.
  5. Type the header Name and Value in the field.



Add headers for a specific URL

  1. Open a script.
  2. Insert a Custom action before the Click and Wait actions that load the object you want to modify. For details, see Editing Script Actions in the documentation.
  3. Change the Target Window to control.
  4. Insert the code provided below.
var getUrl = new AddEventHookCommand({
"eventType": "sendingRequest",
"name": "changeHeaderValue",
"handler":"if(request.url.indexOf(('object you are listening for')) != -1){request.addHeader('cookie', 'myId=1234567');}"
});
getUrl.execute();

If you want to change the header value, use:
request.replaceHeader(name,value);

This code is a listener. What you want to do is "listen" for the object you want to modify. When the agent "hears" the requested object, it will modify the header accordingly.

 

 

 

 

 

  • No labels
  1. Anonymous (login to see details)

    Hello,

    FYI : One ')' is missing after : ('object you are listening for')

    Thanks,

    Quentin

    1. Anonymous (login to see details)

      Thanks! It's fixed now.