2014 marked my third year in a row attending the Dynatrace Global Perform conference in Orlando, FL. The event covers all things APM, and combines engaging breakout sessions with opportunities to learn and share with other performance minded professionals. In addition to the great information, the highlight of the conference for me is meeting the people that shape the Dynatrace products. It is obvious they are passionate about what they do, and every year I leave with confidence that the future of Dynatrace is in great hands.

I am particularly interested in promoting quality through DevOps and automation, so one of the many excellent sessions I attended was “Dynatrace Inside the Continuous Delivery Pipeline” by Martin Etmajer. I believe the goal of automation and repeatability required for continuous delivery adds value even if one does not plan to deploy continuously to production environments. In this session, hearing about automated regression testing through Selenium and the browser agent caught my attention since we have a license for the browser agent but have yet to take full advantage of it.

With my interest piqued, I came home from the conference motivated to get Selenium and our licensed Dynatrace browser agent working together. I found a number of great resources in the online APM community, including these two walkthroughs from the official documentation:

Dynatrace 6.0 Documentation: Diagnose Browser Activity

Dynatrace 6.0 Documentation: Browser Regression Analysis

I could not, however, find a complete guide for what I wanted to accomplish. By drawing on a number of sources and a bit of trial and error, I was able to put together a working example which I published to GitHub (See “Conclusion” section below for the link).  For those that are trying to accomplish the same thing, I wanted to share some lessons I learned along the way:

Lesson 1: Enable Browser support in the System Profile

To record data from the browser agent, an agent group has to be configured in a system profile on the Dynatrace server. I did this by adding an agent group to an existing system profile but neglected to check that the Browser technology was enabled on the general settings of the profile. If you don’t see the Browser related sensors, check this setting.

Lesson 2: Use the 32 bit IE Driver Server and Internet Explorer

Selenium uses an abstraction called the WebDriver to support multiple browser types, and the IEDriverServer is required for Selenium to communicate with Internet Explorer.  I mistakenly assumed that since I had a 64 bit copy of Windows I would need the 64 bit version of the IE Driver Server.  I learned that the Dynatrace browser agent installs to the 32 bit version of IE only, so you need the 32 bit IE Driver Server which will open IE in 32 bit mode, thus making the browser plugins available.

Lesson 3: Browser Agent Environment Variables

When the WebDriver opens IE, the Dynatrace browser agent will not activate unless certain environment variables are set. I found conflicting information on what these variables needed to be, none of which worked for the licensed browser agent. The ones that ended up working for me are:

DT_AGENTNAME – The name of the agent configured in the system profile

DT_SERVER – The host and port of the Dynatrace server / collector.

DT_CLEARCACHE – Clears the browsers cache upon startup if set to true.

DT_AGENTACTIVE – Should always be set to true.

Lesson 4: Get the Dynatrace Helpers from the Easy Travel Demo Source

Dynatrace has published some selenium helper classes which make integration a lot easier, but the links to download these I found are somewhat inconsistent and point to older versions of the code. The Easy Travel source has more recent versions, and as a bonus includes the IE Driver Server mentioned above.

Conclusion

Hopefully this helps others that want to use the browser agent with Selenium get started at least.  To see the sample code, clone or download the GitHub project at https://github.com/d-snyder/dynatrace-selenium.git and follow the instructions in the README.md file. There are also a number of postings in the APM community to glean information from, so I recommend using that as a resource. Two that were particularly helpful to me were:

How to include Dynatrace in your Selenium Tests

How to use your Selenium Tests for automated JavaScript/AJAX Performance Analysis