Debugging Tips for Selenium Test Failures

| by Chris Sims Follow 0 Followers on Jul 06, 2009. Estimated reading time: less than one minute |

While Selenium has gained wide acceptance as a useful tool for automating browser-level tests, tracking down the cause of test failures can take significant time. Daniel Wellman has shared two of his best tricks to greatly reduce debugging time for failed Selenium tests.

The first technique is to capture a screenshot any time a test fails. There are a couple of methods provided to support this: captureScreenshot, and captureScreenshotToString. The post Capture Screenshots of Selenium Failures, on the YouDevise Developer blog provides some example Java code for how this approach might be implemented.

The second technique is to capture the HTML DOM contents when a test fails. For this, Wellman recommends using the method getHtmlSource to capture the contents of the DOM and write them out to a file.

Taking the time to incorporate these two techniques could pay off handsomely in time saved debugging. This is not the first time that Wellman has written about the value of investing in your tools to gain more productivity. What improvements have you made to your toolset, testing or otherwise, that had big payoffs for you? Leave a comment and share with the InfoQ community.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

More detail on capturing screenshots with Selenium by Phil Smith

There are a series of articles on the Cloud Testing Blog ( about capturing screenshots with Selenium.

The Cloud Testing service offers this all plus more with a Pay As You Test model - see for more details.

screenshot is often useless by Tomasz Kaczanowski

I tried once to make screenshots but it was rather useless - you can see only the upper part of the web page which is often not enough

i like the way WebTest Canoo does it

Re: screenshot is often useless by Phil Smith

Hi Tomasz,

You can capture the full browser window, as opposed to just the O/S window with Selenium for Firefox and IE with their native commands.

Cloud Testing has extended this to also work with Safari, Opera and Chrome. This will hopefully be integrated back into the main Selenium release soon.

See for more details.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

3 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you