Information:

Environment

  • Dynatrace Recorder – Local playback
Symptoms

  • Dynamic custom headers
  • Dynamic manual downloads
  • Modifying headers of single/multiple objects
Solution

 

  1. Record a script that includes a Flash interaction. Note which step contains the Flash interaction.
     
  2. When you finish recording a script in the Dynatrace Recorder, save the script to a local drive as a GSL file.
  3. Open the GSL file in a text editor.
  4. Identify the <PageRequest> element that corresponds to the step that contains the Flash interaction.
  5. Within the identified <PageRequest> object, locate the attribute named post_script. The value for the attribute will be enclosed in double quotes, and it will be a base64-encoded string.
    Example:
    "W3sKICAgICJuYW1lIjogImNoZWNrRmxhc2giLAogICAgImV2ZW50VHlwZSI6ICJzZW5kaW5nUmVxdWVzdCIsCiAgICAiaGFuZGxlciI6ICJ2YXIgaGV
    hZGVycyA9IHJlcXVlc3QuZ2V0SGVhZGVycygpO2hlYWRlcnMuYWRkKCdNeWhlYWRlcicsICd0ZXN0Jyk7IHZhciByZXFVcmwgPSByZXF1ZXN0LnVybDs
    gdmFyIGxvYyA9IG5ldyBMb2NhdG9yKCk7IHZhciB3aW4gPSBsb2MuZmluZEZyYW1lKCdnb21lel90b3BbMF0nKTsgdmFyIGZvb3RlckVsID0gd2luLmR
    vY3VtZW50LmdldEVsZW1lbnRCeUlkKCdmb290ZXInKTsgZm9vdGVyRWwuaW5uZXJIVE1MID0gZm9vdGVyRWwuaW5uZXJIVE1MICsgJyBmbGFzaFZlcml
    meSAnICsgcmVxVXJsOyIsCiAgICAidHlwZSI6ICJhZGRFdmVudEhvb2siCn0sCnsKICAgICJ0YXJnZXQiOiB7CiAgICAgICAgInRhcmdldFdpbmRvdyI
    6ICJnb21lel90b3BbMF0uZnJhbWVzWzJdIiwKICAgICAgICAibG9jYXRvcnMiOiBbWyJjc3MiLCAiI0dQQ29ycG9yYXRlQWN0aW9ucyJdLCBbImRvbSI
    sICJkb2N1bWVudC5nZXRFbGVtZW50QnlJZChcIkdQQ29ycG9yYXRlQWN0aW9uc1wiKSJdLCBbImNzcyIsICJodG1sIGJvZHkgZW1iZWQiXV0KICAgIH0
    sCiAgICAiY29vcmRzIjogW3sKICAgICAgICAieCI6IDEwNCwKICAgICAgICAieSI6IDY2CiAgICB9LAogICAgewogICAgICAgICJ4IjogMTQxLAogICAK
    gICAgICJ5IjogNjkKICAgIH0sCiAgICB7CiAgICAgICAgIngiOiAxNDksCiAgICAgICAgInkiOiA0NgogICAgfSwKICAgIHsKICAgICAgICAieCI6IDE
    1NSwKICAgICAgICAieSI6IDM5CiAgICB9XSwKICAgICJ0eXBlIjogIm1vdXNlbW92ZSIKfSwKewogICAgInRhcmdldCI6IHsKICAgICAgICAidGFyZ2V
    0V2luZG93IjogImdvbWV6X3RvcFswXS5mcmFtZXNbMl0iLAogICAgICAgICJsb2NhdG9ycyI6IFtbImNzcyIsICIjR1BDb3Jwb3JhdGVBY3Rpb25zIl0
    sIFsiZG9tIiwgImRvY3VtZW50LmdldEVsZW1lbnRCeUlkKFwiR1BDb3Jwb3JhdGVBY3Rpb25zXCIpIl0sIFsiY3NzIiwgImh0bWwgYm9keSBlbWJlZCJ
    dXQogICAgfSwKICAgICJ4IjogMTU2LAogICAgInkiOiAzOSwKICAgICJ0eXBlIjogImNsaWNrIgp9LAp7CiAgICAiY3JpdGVyaWEiOiAibmV0d29yayI
    sCiAgICAidHlwZSI6ICJ3YWl0Igp9LAp7CiAgICAiY3JpdGVyaWEiOiAiZWxlbWVudF9tYXRjaCIsCiAgICAidGFyZ2V0IjogewogICAgICAgICJ0YXJ
    nZXRXaW5kb3ciOiAiZ29tZXpfdG9wWzBdIiwKICAgICAgICAibG9jYXRvcnMiOiBbWyJkb20iLCAiZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoXCJmb29
    0ZXJcIikiXV0KICAgIH0sCiAgICAibWF0Y2giOiAiaHR0cHM6Ly9nbG9iYWxwcmltZS5kYi5jb20vR2xvYmFsUHJpbWVDQVByb2R1Y2VyL21lc3NhZ2V
    icm9rZXIvc2VjdXJlYW1mLnR4dCIsCiAgICAidHlwZSI6ICJ2YWxpZGF0ZSIKfV0="
  6. Highlight the value of the post_script value. Be sure to exclude the enclosing double quotes, and be sure to include all characters if the value spans multiple lines.
  7.  Copy the highlighted text, navigate to:    http://www.opinionatedgeek.com/dotnet/tools/base64decode/ , and paste the copied text into the text area, then click Decode.
  8.  The following portion of the script is the part that was added:
    {
    "name": "checkFlash",

    "eventType": "sendingRequest",

    "handler": "var headers = request.getHeaders();headers.add('Myheader', 'test'); var reqUrl = request.url; var loc = new Locator(); var win = loc.findFrame('gomez_top[0]'); var footerEl = win.document.getElementById('footer'); footerEl.innerHTML = footerEl.innerHTML + ' flashVerify ' + reqUrl;",

    "type": "addEventHook"

    }
  9.  This part of the script is the first action in the step, and it defines an event handler, named checkFlash. This checkFlash event handler "listens" for the sendingRequest event, and then executes the defined handler JavaScript code when the event occurs.
  10.  The handler JavaScript sets a header value, Myheader, as a test so that it is visible on the Headers tab for the requested object in the Results pane.
  11.  The script then retrieves the URL of the request, which is the POST that results from clicking on the Flash application during the GSL script playback. The URL of that detected POST is appended to the innerHTML of the DOM object with the ID of footer, which can be found at the bottom of the web page.
  12.  If you edit the script, re-encode it as base64: copy the edited script into the text area in http://www.opinionatedgeek.com/dotnet/tools/Base64Encode/Default.aspx , and click Encode.
    The resulting base64 string can be copied back into the value of the post_script attribute of the corresponding <PageRequest> step in the GSL file.
  13.  Save the GSL file, then open it in the Dynatrace Recorder and execute it against the Firefox agent.
    Note that the last action of the script is a Validate action, which tries to match the text of the POST URL against the DOM object with the id of footer.

 

 

 

 

 

  • No labels