Automating the Capture of Web Timings with Selenium RC

6 Nov

This is a follow up to

The article gives sample code for Selenium 2 / Web Driver. Here I present tips to do equivalent for Selenium RC:

//some selenium code here to navigate site to get performance data for

timingJavaScript = “var performance = window.performance || window.webkitPerformance || window.mozPerformance || window.msPerformance || {}; var timings = performance.timing || {}; timings.domContentLoadedEventEnd;”;

timingResult = selenium.getEval(timingJavaScript);

//now an do whatever with the timingResult

Notice that the last line of javascript in the timing script simply lists the desired variable so that getEval can return it. You don’t specifically add a return statement.

Note that unless your language of choice can handle the the javascript object (with timing statistics as object properties), you may have to return the individual properties of interest as in example above, where I return specific property of the timings object. Or you would have to preprocess in javascript into a data format like a CSV or XML string to pass back to your language. If your language can natively handle it, with typecasting, etc. then you can just return the whole object, named “timings” above instead of the property “timings.domContentLoadedEventEnd”.

Note also that this isn’t necessarily the optimal javascript code to use, but at least it seems to work as an example.

Also, this was response from David Burns of the original article when I asked if the API worked with Selenium RC:

This should work on either Selenium RC or on WebDriver. All you really need is the JavaScript that I use in executeScript and run it in the window context. For RC I think its “var window = this.browserbot.getUserWindow()” to get the window.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Anastasia Writes

politics, engineering, parenting, relevant things over coffee.

One Software Tester

Trying To Make Sense Of The World, One Test At A Time

the morning paper

an interesting/influential/important paper from the world of CS every weekday morning, as selected by Adrian Colyer

RoboSim (Robot Simulator)

Visualize and Simulate the Robotics concepts such as Localization, Path Planning, P.I.D Controller


open notebook

a happy knockout mouse.

my journey into computer science

Perl 6 Advent Calendar

Something cool about Perl 6 every day


Inspire and spread the power of collaboration

Niraj Bhatt - Architect's Blog

Ruminations on .NET, Architecture & Design

Pete Zybrick

Bell Labs to Big Data

Seek Nuance

Python, technology, Seattle, careers, life, et cetera...


New Era of Test Automation

Der Flounder

Seldom updated, occasionally insightful.

The 4T - Trail, Tram, Trolley, Train

Exploring Portland with the 4T

Midnight Musings

Thoughts on making art

Automation Guide

The More You Learn The More You Play...!

The Performance Engineer



Thoughts related to software development

%d bloggers like this: