Welcome!

Java Authors: Esmeralda Swartz, Trevor Parsons, Sandi Mappic, Lori MacVittie, JP Morgenthal

Related Topics: AJAX & REA, Java

AJAX & REA: Article

Selenium Tests for Automated JavaScript/AJAX Performance Analysis

A step-by-step guide

With more than 3 million downloads, Selenium is a functional testing framework. It allows web developers and QA professionals to automatically test how an application functions on multiple browsers, such as Firefox, Internet Explorer and Chrome and across operating systems, such as different versions of Windows and Mac OS.

The FREE dynaTrace AJAX Edition on the other side is probably the best web site performance analysis tool for Internet Explorer 6, 7 and 8.  Here is what John Resig, Creator of jQuery has to say about it: “I’m very impressed with dynaTrace AJAX Edition’s ability to get at the underlying “magic” that happens inside a browser: page rendering, DOM method execution, browser events, and page layout calculation. Much of this information is completely hidden from developers and I’ve never seen it so easily collected into a single tool. Huge kudos to dynaTrace for revealing this information and especially so for making it happen in Internet Explorer

Combine best of breed tools for Automated Performance Analysis
If we look at these two tools it almost seems logical to use them in combination in order to automatically capture performance data from within the browser for every Selenium Test you execute.

Why would you want to do that?

In case your Selenium Tests identify a problem – whether it is a functional issue (page not working correctly) or a performance problem (page are much slower in the latest build) – the data that is automatically captured by dynaTrace AJAX contains all information necessary for your web engineers to figure out the root cause of the problem. Without this information, your engineers probably go ahead and manually reproduce the error by executing and debugging through the test case manually. Manual work means additional time and effort – and that’s what can be avoided. Best of all – BOTH TOOLS ARE FREE!!

How it works – Example on testing Google Search
Selenium has multiple options to execute tests. Either use your HTML Test Suites that define the individual test cases in HTML Tables or use a programming language such as Java and “code” your tests. Let’s have a look at these two scenarios and how you can get Selenium to work with the dynaTrace AJAX Edition.

The integration basics are explained in Automation with dynaTrace AJAX Edition and  in Advanced Timing and Argument Capturing. The dynaTrace AJAX Agent that runs as an Internet Explorer Add-On gets activated and is configurable via several environment variables. DT_IE_AGENT_ACTIVE=true activates the Add-On so that it collects data from the current browser session. DT_IE_SESSION_NAME can be used to specify the recorded session name, e.g.: MySeleniumTest123. DT_IE_SERVER_HOST and DT_IE_SERVER_PORT can be used to connect to a dynaTrace AJAX Edition client that runs on a different machine – this is useful when you want to centralize data capturing. DT_IE_CLEAR_CACHE=true causes the Add-On to clear the browser cache before any actions are executed – this is very useful when you want to test your web sites cache behaviour.

These environment variables need to be set for the browser instance that runs the tested website. The browser is launched by the selenium server process. Therefore we have to set these environment variables for that server process as they are propagated to all processes that get launched from it.

Requirement: The dynaTrace AJAX Edition must be running on the local machine in order for the launched browser instances to connect to it. You can also run the AJAX Edition on a different machine – in this case you need to specify DT_IE_SERVER_NAME with the name of the machine where the AJAX Edition runs on.

Running an HTML Test Suite
The following batch file sets the necessary environment variables to a) activate the dynaTrace AJAX Add-On in IE and b) specifiy a custom session name:

@echo off
set SELENIUM_RC=C:\selenium\selenium-server.jar
set SCRIPT_PATH=%~dp0

rem dynaTrace AJAX IE agent settings
set DT_IE_AGENT_ACTIVE=true
set DT_IE_SESSION_NAME=Google_SeleniumTest

java -jar %SELENIUM_RC% -log exec.log -htmlSuite "*iexplore" "http://www.google.com"
"%SCRIPT_PATH%\GoogleSuite.html" "%SCRIPT_PATH%\GoogleResults.html"

Before I run this script I make sure to launch the dynaTrace AJAX Edition. When I execute the script Selenium will launch the HtmlRunner in a separate browser instance and will then launch the browser that will execute your test steps. The second browser instance will have the active dynaTrace AJAX agent. You can tell this by the changed IE icon as well as an increasing number in the Captured Events displayed in the dynaTrace AJAX Edition IE Toolbar:

Executing an HTML Test Suite with dynaTrace AJAX capturing  performance data

Executing an HTML Test Suite with dynaTrace AJAX capturing performance data

Note: Even though both browser instances use the DT_IE_XXX environment variables, the AJAX Edition will not collect information from the Selenium Test Runner. The Test Runner runs as an HTA Application which prevents the AJAX Edition Add-On from being loaded. In this case it is an advantage as we are not interested in the performance of the Selenium Runner.

Once the test is done and the browser is closed we can explore the results captured in the dynaTrace AJAX Edition:

dynaTrace AJAX Edition captured performance data from the Selenium  Test Run using the configured Session Name

dynaTrace AJAX Edition captured performance data from the Selenium Test Run using the configured Session Name

The session name is the one we passed in via DT_IE_SESSION_NAME – Google_SeleniumTest in this case. You will see a URL to a local file. That is a file that Selenium opens which then actually opens the URL of the test application. Simply ignore this line and focus on those URLs of your test scenario.

Running Test Case from Java (or JUnit)
Many folks out there use the option to write their Selenium tests in Java – either using JUnit as executing framework or just using the DefaultSelenium proxy in a console app or custom test framework. The approach here is the same as explained in the Html Test Case Use Case. We have to start the selenium server with the DT_IE_XXX environment variables. Here is the batch file I use:

@echo off
set SELENIUM_RC=C:\selenium\selenium-server.jar
set SCRIPT_PATH=%~dp0

rem IE agent settings
set DT_IE_AGENT_ACTIVE=true
set DT_IE_SESSION_NAME=dynaTrace_Selenium

java -jar %SELENIUM_RC%

Here is my Java application that executes the same Google Search test steps as my HTML Test Suite:

public static void main(String args[]) {
Selenium selenium
= new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com");

selenium.
start();
selenium.
open("http://www.google.com");
selenium.
type("q", "dynatrace");
selenium.
click("btnG");

selenium.
stop();
}

The result is the same. The Selenium server launches two browser instances. The first loads the Selenium Runner which won’t be analyzed by dynaTrace AJAX as it is an HTA Application. The second launches google.com and searches for dynaTrace. The following screenshot shows this captured session with the name dynaTrace_Selenium:

dynaTrace AJAX Edition captured the data from the test steps  executed by my Java application

dynaTrace AJAX Edition captured the data from the test steps executed by my Java application

Where to go from here?
The feedback I get from our user community is that this type of integration is a huge time saver. Whenever their Selenium tests fail, the in-depth performance data from the test run is available for analysis. A key point to remember is that this is not just about performance. As the AJAX Edition captures full JavaScript traces, DOM Access, Network and Rendering activities, it makes it very easy to identify all functional and deployment-related problems. Analyzing the dynaTrace AJAX data allows one to identify whether the problem is caused by files that didn’t get deployed on the web server, whether a new JavaScript library was introduced that wasn’t fully tested yet, or whether the problem actually originates on the server-side code. Check out the following additional resources to learn more about how to analyze the data that is captured: Getting Started with dynaTrace AJAX Edition (includes links to real-life web site analysis examples), Why Web 2.0 requires full End-to-End visibility and Learn how Monster.com uses the AJAX Edition for their web-site

In case you have questions on this topic, either comment on the blog or use the comment feature on our dynaTrace AJAX Community Portal.

Related reading:

  1. 5 Steps to Automate Browser Performance Analysis with Watir and dynaTrace AJAX Edition I’ve recently been working with several clients to analyze their...
  2. Ensuring Web Site Performance – Why, What and How to Measure Automated and Accurately It is a fact that end user response time is...
  3. Selenium/BrowserMob integration with dynaTrace Selenium is a free Web Application Testing System. It gained...
  4. Automated Performance Analysis: What’s going on in my ASP.NET or ASP.NET MVC Application? I’ve spent some time in the last weeks playing with different...
  5. Week 6 – How to Make Developers Write Performance Tests I had an interesting conversation with our Test Automation team...

More Stories By Andreas Grabner

Andreas Grabner has more than a decade of experience as an architect and developer in the Java and .NET space. In his current role, Andi works as a Technology Strategist for Compuware and leads the Compuware APM Center of Excellence team. In his role he influences the Compuware APM product strategy and works closely with customers in implementing performance management solutions across the entire application lifecycle. He is a frequent speaker at technology conferences on performance and architecture-related topics, and regularly authors articles offering business and technology advice for Compuware’s About:Performance blog.

@ThingsExpo Stories
The Internet of Things will greatly expand the opportunities for data collection and new business models driven off of that data. In her session at Internet of @ThingsExpo, Esmeralda Swartz, CMO of MetraTech, will discuss how for this to be effective you not only need to have infrastructure and operational models capable of utilizing this new phenomenon, but increasingly service providers will need to convince a skeptical public to participate. Get ready to show them the money! Speaker Bio: Esmeralda Swartz, CMO of MetraTech, has spent 16 years as a marketing, product management, and busin...
Samsung VP Jacopo Lenzi, who headed the company's recent SmartThings acquisition under the auspices of Samsung's Open Innovaction Center (OIC), answered a few questions we had about the deal. This interview was in conjunction with our interview with SmartThings CEO Alex Hawkinson. IoT Journal: SmartThings was developed in an open, standards-agnostic platform, and will now be part of Samsung's Open Innovation Center. Can you elaborate on your commitment to keep the platform open? Jacopo Lenzi: Samsung recognizes that true, accelerated innovation cannot be driven from one source, but requires a...
SYS-CON Events announced today that Red Hat, the world's leading provider of open source solutions, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Red Hat is the world's leading provider of open source software solutions, using a community-powered approach to reliable and high-performing cloud, Linux, middleware, storage and virtualization technologies. Red Hat also offers award-winning support, training, and consulting services. As the connective hub in a global network of enterprises, partners, a...
P2P RTC will impact the landscape of communications, shifting from traditional telephony style communications models to OTT (Over-The-Top) cloud assisted & PaaS (Platform as a Service) communication services. The P2P shift will impact many areas of our lives, from mobile communication, human interactive web services, RTC and telephony infrastructure, user federation, security and privacy implications, business costs, and scalability. In his session at Internet of @ThingsExpo, Robin Raymond, Chief Architect at Hookflash Inc., will walk through the shifting landscape of traditional telephone a...
SYS-CON Events announced today that Matrix.org has been named “Silver Sponsor” of Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Matrix is an ambitious new open standard for open, distributed, real-time communication over IP. It defines a new approach for interoperable Instant Messaging and VoIP based on pragmatic HTTP APIs and WebRTC, and provides open source reference implementations to showcase and bootstrap the new standard. Our focus is on simplicity, security, and supporting the fullest feature set.
BSQUARE is a global leader of embedded software solutions. We enable smart connected systems at the device level and beyond that millions use every day and provide actionable data solutions for the growing Internet of Things (IoT) market. We empower our world-class customers with our products, services and solutions to achieve innovation and success. For more information, visit www.bsquare.com.
How do APIs and IoT relate? The answer is not as simple as merely adding an API on top of a dumb device, but rather about understanding the architectural patterns for implementing an IoT fabric. There are typically two or three trends: Exposing the device to a management framework Exposing that management framework to a business centric logic • Exposing that business layer and data to end users. This last trend is the IoT stack, which involves a new shift in the separation of what stuff happens, where data lives and where the interface lies. For instance, it’s a mix of architectural style...
SYS-CON Events announced today that SOA Software, an API management leader, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. SOA Software is a leading provider of API Management and SOA Governance products that equip business to deliver APIs and SOA together to drive their company to meet its business strategy quickly and effectively. SOA Software’s technology helps businesses to accelerate their digital channels with APIs, drive partner adoption, monetize their assets, and achieve a...
From a software development perspective IoT is about programming "things," about connecting them with each other or integrating them with existing applications. In his session at @ThingsExpo, Yakov Fain, co-founder of Farata Systems and SuranceBay, will show you how small IoT-enabled devices from multiple manufacturers can be integrated into the workflow of an enterprise application. This is a practical demo of building a framework and components in HTML/Java/Mobile technologies to serve as a platform that can integrate new devices as they become available on the market.
SYS-CON Events announced today that Utimaco will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Utimaco is a leading manufacturer of hardware based security solutions that provide the root of trust to keep cryptographic keys safe, secure critical digital infrastructures and protect high value data assets. Only Utimaco delivers a general-purpose hardware security module (HSM) as a customizable platform to easily integrate into existing software solutions, embed business logic and build s...
Connected devices are changing the way we go about our everyday life, from wearables to driverless cars, to smart grids and entire industries revolutionizing business opportunities through smart objects, capable of two-way communication. But what happens when objects are given an IP-address, and we rely on that connection, sometimes with our lives? How do we secure those vast data infrastructures and safe-keep the privacy of sensitive information? This session will outline how each and every connected device can uphold a core root of trust via a unique cryptographic signature – a “bir...
Internet of @ThingsExpo Silicon Valley announced on Thursday its first 12 all-star speakers and sessions for its upcoming event, which will take place November 4-6, 2014, at the Santa Clara Convention Center in California. @ThingsExpo, the first and largest IoT event in the world, debuted at the Javits Center in New York City in June 10-12, 2014 with over 6,000 delegates attending the conference. Among the first 12 announced world class speakers, IBM will present two highly popular IoT sessions, which will take place November 4-6, 2014 at the Santa Clara Convention Center in Santa Clara, Calif...
Almost everyone sees the potential of Internet of Things but how can businesses truly unlock that potential. The key will be in the ability to discover business insight in the midst of an ocean of Big Data generated from billions of embedded devices via Systems of Discover. Businesses will also need to ensure that they can sustain that insight by leveraging the cloud for global reach, scale and elasticity.
WebRTC defines no default signaling protocol, causing fragmentation between WebRTC silos. SIP and XMPP provide possibilities, but come with considerable complexity and are not designed for use in a web environment. In his session at Internet of @ThingsExpo, Matthew Hodgson, technical co-founder of the Matrix.org, will discuss how Matrix is a new non-profit Open Source Project that defines both a new HTTP-based standard for VoIP & IM signaling and provides reference implementations.

SUNNYVALE, Calif., Oct. 20, 2014 /PRNewswire/ -- Spansion Inc. (NYSE: CODE), a global leader in embedded systems, today added 96 new products to the Spansion® FM4 Family of flexible microcontrollers (MCUs). Based on the ARM® Cortex®-M4F core, the new MCUs boast a 200 MHz operating frequency and support a diverse set of on-chip peripherals for enhanced human machine interfaces (HMIs) and machine-to-machine (M2M) communications. The rich set of periphera...

SYS-CON Events announced today that Aria Systems, the recurring revenue expert, has been named "Bronze Sponsor" of SYS-CON's 15th International Cloud Expo®, which will take place on November 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Aria Systems helps leading businesses connect their customers with the products and services they love. Industry leaders like Pitney Bowes, Experian, AAA NCNU, VMware, HootSuite and many others choose Aria to power their recurring revenue business and deliver exceptional experiences to their customers.
The Internet of Things (IoT) is going to require a new way of thinking and of developing software for speed, security and innovation. This requires IT leaders to balance business as usual while anticipating for the next market and technology trends. Cloud provides the right IT asset portfolio to help today’s IT leaders manage the old and prepare for the new. Today the cloud conversation is evolving from private and public to hybrid. This session will provide use cases and insights to reinforce the value of the network in helping organizations to maximize their company’s cloud experience.
The Internet of Things (IoT) is making everything it touches smarter – smart devices, smart cars and smart cities. And lucky us, we’re just beginning to reap the benefits as we work toward a networked society. However, this technology-driven innovation is impacting more than just individuals. The IoT has an environmental impact as well, which brings us to the theme of this month’s #IoTuesday Twitter chat. The ability to remove inefficiencies through connected objects is driving change throughout every sector, including waste management. BigBelly Solar, located just outside of Boston, is trans...
SYS-CON Events announced today that Matrix.org has been named “Silver Sponsor” of Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Matrix is an ambitious new open standard for open, distributed, real-time communication over IP. It defines a new approach for interoperable Instant Messaging and VoIP based on pragmatic HTTP APIs and WebRTC, and provides open source reference implementations to showcase and bootstrap the new standard. Our focus is on simplicity, security, and supporting the fullest feature set.
Predicted by Gartner to add $1.9 trillion to the global economy by 2020, the Internet of Everything (IoE) is based on the idea that devices, systems and services will connect in simple, transparent ways, enabling seamless interactions among devices across brands and sectors. As this vision unfolds, it is clear that no single company can accomplish the level of interoperability required to support the horizontal aspects of the IoE. The AllSeen Alliance, announced in December 2013, was formed with the goal to advance IoE adoption and innovation in the connected home, healthcare, education, aut...