If you are not familiar with what dynaTrace can do in Continuous Integration I recommend reading my post dynaTrace in Continuous Integration - The Big Picture
Why integrating dynaTrace with Selenium?
clickThroughMenus is a Use Case that has a big change in Server-Time compared to the previous test run
The Sample Selenium Script
Let's assume we do have the following Selenium Script that tests our GoSpace Sample Application:
Using the dynaTrace Selenium Runner
The easiest option is to use the dynaTrace Selenium Runner (com.dynatrace.webautomation.DynaTraceSeleniumRunner). This runner will automatically set the test method name as timer name. It does this by capturing the test method name and, when executing the "open" method appends it to the URL. Here is how the script looks like when using the dynaTrace Runner:
If you already have a custom Selenium Runner you can either merge the necessary calls from DynaTraceSeleniumRunner into your Runner or use one of the two other options you have.
Using the dynaTrace Selenium Helper
The DynaTraceSeleniumHelper (com.dynatrace.webautomation.DynaTraceSeleniumHelper) is a class that provides the functionality to set timers from existing scripts without using the dynaTrace Selenium Runner. Here is how to use the DynaTraceSeleniumHelper on the original sample script:
DynaTraceSeleniumHelper.forSelenium returns an instance of the Helper Class encapsulating the passed Selenium instance. The helper class provides an "open" method that automatically sets the current test method name as Timer Name. It also provides addTimerName and removeTimerName for subtimer definition.
The "open" method also allows you to specify a custom timer name. The method setTimerName also allows you to change the current Timer Name at any time.
Here is the Browser Summary Dashlet when executing a set of tests that have been converted to use the DynaTraceSeleniumHelper. You can also see the Subtimer "Do Search" as shown in the Selenium Script:
Using DynaTraceSelenium instead of DefaultSelenium
The third option is to use DynaTraceSelenium (com.dynatrace.webautomation.DynaTraceSelenium) instead of your DefaultSelenium instance. The only thing you have to change is to create an instance of DynaTraceSelenium. It overwrites the open method and also provides timer functions. You can also combine it with the DynaTraceSeleniumHelper class if you want to.
Every open method will automatically start a new timer with the name of the current test method as timer name.
Conclusion and Next Steps
As you can see, it is easy to include dynaTrace into your Selenium Tests. We provide multiple different approaches on how to set the Timer Names.
Download the latest version of our Demo Applications which including a full featured sample or download the Selenium and WebDriver Integration which only includes the Helper classes as described in this article.
Not Logged In? Customers and AJAX Edition Users Login with your Community Account