This has come up again and again on the Selenium user list and when liaising with clients that are using Selenium: How to report bugs to the Selenium team?. The problem is more subtle than you would think. Selenium2 can be driven by a number of languages, has multiple browsers that can be driven, and tastes around build technologies vary (especially within the dev team).
h1. Groovy scripts are the most sharable, terse yet capable in my opinion

Consider this example for using Firefox for searching for “Selenium” on the ThoughtWorks site:


import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.By
import static org.junit.Assert.assertTrue

def driver = new FirefoxDriver()
driver.get ""

def searchField = driver.findElement("edit-search-block-form-1"))

def searchBtn = driver.findElement("edit-submit"))

def success = driver.getPageSource().contains("to run the same acceptance tests")

println "WebDriver test complete"


The bug-reporter are able to capture everything about the problem in a single script, with no build-file dependency. They can juggle the version of Selenium quite easily in the @Grab line at the top of the file. That might be important if the bug exists in one version of Selenium2 but not another. If the user is familiar with xUnit style programming they can keep lines similar to the assertTrue(…) line, but if they are not, they can code something rudimentary themselves. As this gets uploaded to the Selenium project issue tracker, it does not matter whether it is an attachment, or cut/paste into the body of the issue. The bug-reporter may also be pleased to know that Groovy itself doesn’t really need to be installed: see later.

From the point of view of the selenium team (who on average are pretty good at Java and hence Groovy too), the script can be run more easily than anything that has a build file, or is just a fragment of logic. The @Grapes business means that only Groovy is a prerequisite install beyond the Java install they already have. Grapes will download the dependencies (somewhat silently) if they are no cached and puts them in [your home directory]/.ivy/ making it easy. Lastly, the Selenium developer will be able to attach a debugger as easily as they would to a Java process.

Proprietary nature of pages?

Some clients don’t want their pages to appear in public before they are ready. In that case you need to consider trusting one or two members of the Selenium dev team with a single problematic page from your being-built application. The MAFF plugin for Firefox will do admirable job of saving a page including state and scripts. You could mount the result of a save on an obscure URL, or send it as a zip to the developer handing your bug report (presumably after a conversation in email). The MAFF trick is a neat one, as it allows you to omit mention of any pages and Selenium operations that are not directly related to the bug in question. Even if your preferred browser is Internet Explorer, this Firefox workflow will save a site that is perfectly navigable by IE.

Getting up to speed with Groovy.

Java is required by Groovy. It is Windows, Mac and Linux compatible. It’s already on Mac versions up to Snow Leopard. For Lion, you have to install it yourself . For Windows and Linux, go to and click through to the right download. If it’s asking you whether you want “runtime environment” or “developer kit” choose the latter. Test Java on the command line like so:

C:\> java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-10M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)

A reboot may be necessary, to get Java’s ‘bin’ directory into the PATH environmental variable. If you’re advanced with such things, you already know about tricks to negate the need for the reboot.

For Groovy itself, things are slightly simpler. Download the “binary release” from the Groovy website Unzip it and make sure the pertinent ‘bin’ directory is in your path. Test it like so:

C:\> groovy --version
Groovy Version: 1.8.4 JVM: 1.6.0_29


PS – Groovy can be terser still than the test-script represented above – I just didn’t want to scare anyone :)

blog comments powered by Disqus


November 14th, 2011