Andreas Grabner About the Author

Andreas Grabner has been helping companies improve their application performance for 15+ years. He is a regular contributor within Web Performance and DevOps communities and a prolific speaker at user groups and conferences around the world. Reach him at @grabnerandi

Selenium/BrowserMob integration with dynaTrace

Selenium is a free Web Application Testing System. It gained lots of popularity since it is available. It’s integration to FireFox – which allows instant record/replay as well as the scripting option - makes it a great tool for functional web testing.

BrowserMob on the other side leverages Selenium by providing an automated load-testing environment for Selenium scripts all configurable online via a Web Dashboard.

Tagging Web Requests

In my recent blog post – Get more out of functional web testing: How to correlate test reports with server side log information? – I discussed the problem that testing results are usually not linked to the log and diagnostics information captured by the application under test. The blog entry offered a way to link the two sides using HTTP Tagging via an HTTP Proxy. Tagging individual Web Requests allows linking each individual request executed by the testing tool with the transactions that are executed on the server side. Your logging framework or diagnostics solution can then take this tag and link the transaction to the originating web request.

Tagging Web Requests with Selenium

Selenium offers a feature to add additional HTTP Tags to each Web Request via DefaultSelenium.addCustomRequestHeader. This feature allows achieving the exact same result as I explained in my previous blog entry.
In order to make it easy for Selenium script developers to use this feature we (Patrick Lightbody from BrowserMob and I) came up with the following 2 requirements:

  1. every test case should automatically be tagged with the test case name. This ensures that we can link each transaction to the test case
  2. the scripter must have the option to change the tagged value within a test case to allow more granular linking to individual actions in a test case

The implementation for these requirements resulted in

  1. a custom TestRunner class (DynaTraceSeleniumRunner) that sets the default value for the HTTP Header to the current test case name
  2. a custom Selenium class (DynaTraceSelenium) that offers the scripter to change the value for the HTTP Header

With these changes a tester can now create a script like this:

Selenium Test Script

Selenium Test Script

When executing the script – the first request to the frontend URL will be tagged with the name “MyTestUseCase”. This tagged value will later be changed with the call to selenium.setTimerName meaning that all login web requests will be tagged with the value “Login”, all search related requests with the name “Search” and logout with “Logout”.

Using dynaTrace on the application that we are testing allows us to pick-up those HTTP Headers and enables us to exactly identify the individual transactions that came in from the individual steps in the test case.

Step 1: Starting from the Tagged Web Requests View

Server Side Transactions grouped by the passed HTTP Tag

Server Side Transactions grouped by the passed HTTP Tag

Step2: We can drill into the individual web requests that were executed, e.g.: lets see the 14 requests for the Search action

We see all individual requests for the actual documents and embedded objects

We see all individual requests for the actual documents and embedded objects

Step 3: Check the outliers

Interesting here to see is that the average sum for all Search actions was 764.32 ms. In the detailed drill down we however see that we had one request taking 10.45 seconds. With another Drill-Into we can examine the one request that took so long:

PurePath showing hotspots and exact transaction execution path down to the method level

PurePath showing hotspots and exact transaction execution path down to the method level

Step 4: Analyse Log Messages

Additionally to drilling into a transaction we can go the other way round by drilling from a problem to the originating test case. Let’s start by looking at the log outputs that were automatically captured bydynaTrace.

Shows all log messages logged with log4j or log4net

Step 5: Who caused the log message?

Now we can drill to the Tagged Web Requests to see which test case action caused the 10 highlighted log messages.

Two requests from the Login and Search Action caused this log message

Two requests from the Login and Search Action caused this log message

Conclusion

With additional functionality like adding custom HTTP Headers it will be possible to link test results with server side information as described in my blog entry without needing an additional proxy layer that takes care of the tagging.

If you want to know more about the specific Integration from Selenium/BrowserMob with dynaTrace feel free to contact me. dynaTrace Customers/Partners can access a sample on the dynaTrace Community Portal

Comments

  1. One question, does this work with PhP/MySQL web sites?
    and with PhP for Selenium? thanks, –JJ

  2. Hi
    dynaTrace currently supports Java and .NET Applications. PhP is currently not on the supported list of technologies.

  3. Hi Andreas,

    I am trying to integrate dynaTrace with Selenium script for performance testing and I am really confused about the path and way to do it.Can you suggest me something to start on it.I am totally new in both the tools.

    Thanks,
    Anuj

  4. @Anuj
    We two had a brief email conversation. I wanted to update this blog as well. You can find more information on dynaTrace and Selenium in our Community Portal: https://community.dynatrace.com/community/display/DL/Selenium+Integration
    Access to this community portal page is restricted to our commercial users of dynaTrace.
    There is also an integration option of the FREE dynaTrace AJAX Edition with tools like Selenium/Watir/SilkTest/… – for this – check out the following blog entry: http://blog.dynatrace.com/2009/11/04/5-steps-to-automate-browser-performance-analysis-with-watir-and-dynatrace-ajax-edition/
    Let me know if this helps

Trackbacks

  1. [...] Selenium/BrowserMob integration with dynaTrace Performance … By Andreas Grabner When executing the script – the first request to the frontend URL will be tagged with the name “MyTestUseCase”. This tagged value will later be changed with the call to selenium.setTimerName meaning that all login web requests will be … Performance, Scalability and… – http://blog.dynatrace.com/ [...]

  2. Selenium/BrowserMob integration with dynaTrace Performance, Scalability and Architecture – Java and .NET Application Performance Management (dynaTrace Blog)…

    Thank you for submitting this cool story – Trackback from DotNetShoutout…

Comments

*


− 1 = three