I’ve recently been working with several clients to analyze their website performance with the dynaTrace AJAX Edition. Based on our findings their JavaScript code, usage of 3rd party frameworks, use of AJAX, embedded objects, and caching strategies have been changed over multiple iterations. After each iteration, it is good practice to verify if the changes improved overall performance and also didn’t break the functionality of the page. Instead of executing the main use cases manually while running a performance analysis tool like dynaTrace it makes sense to automate this whole process.

There are several test automation tools out there that actively drive the browser – like Selenium, Watir, WebAii, QTP, SilkTest, … – Key is to not only to automate test execution but also automate performance analysis. The dynaTrace AJAX Edition enables this by automatically collecting and storing performance data for each browser session. With that integration you can run your automated tests to verify your functionality as well as capturing the data for performance analysis. Here are 5 quick steps to automate test execution and performance analysis with Watir and dynaTrace AJAX Edition.

Step 1: Installation

Step 2: Watir Script Generation

As an example we create a Watir script that opens a new browser, opens the google.com search page and searches for Watir. As a setup step we have to define several environment variables that activate the dynaTrace AJAX Agent in IE. By default – the dynaTrace AJAX Agent is not activated when launching a browser from outside the dynaTrace AJAX Edition Client. With the following environment variables you can control the dynaTrace AJAX Agent:

  • DT_IE_AGENT_ACTIVE: true or false to activate or deactivate the agent
  • DT_IE_SESSION_NAME: name of the captured performance session. If you have a test run # or test suite name I would use the name here. This is great to identify a captured performance session by its logical name
  • (optional) DT_IE_SERVER_HOST: The machine where the dynaTrace AJAX Edition Client runs
  • (optional) DT_IE_SERVER_PORT: The port of the dynaTrace AJAX Edition Client
  • (optional) DT_IE_CLEAR_CACHE: If true – the dynaTrace AJAX Agent will first clear the browser’s file cache before starting with any execution

Here is the script (Watir Sample Script)that first sets the env-variables and then executes the test steps:

Watir Script testing Google with enabled dynaTrace AJAX Agent
Watir Script testing Google with enabled dynaTrace AJAX Agent

Step 3: Preparing your test machine

Before running a script you have to

  1. Start the dynaTrace AJAX Edition Client (from the Start Menu -> Programs -> dynaTrace -> dynaTrace AJAX Edition)
  2. Close all current browsers

Its recommended to have the AJAX Edition Client running on your local machine where you also execute your test scripts. You can however run it on a separate machine. In this case you would need to specify the DT_IE_SERVER_HOST environment variable to the hostname that runs the dynaTrace AJAX Edition Client.

dynaTrace AJAX Edition after Startup