Using Twist With Different Selenium Versions

When you start using Twist you will find that the twist team have baked selenium into twist.
You will also find that the version of selenium that has been integrated has some quirks.

Here is a simple guide for using any Selenium version with Twist.

You can also use this guide to help you implement other drivers like WebDriver.

Step 1
Add the selenium-java-client-driver.jar and the selenium-server.jar of your preferred selenium release (I’m going to be using my old friend selenium.0.9.2) to the Twist project class path, make sure these jars are loaded first in the class path order.

Step 2
You need to create a factory class that will create the Selenium instance for your test suite.

For example, let’s create “” in the Twist source folder.

import; import java.util.Properties;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import org.openqa.selenium.server.cli.RemoteControlLauncher;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class SeleniumFactory { private SeleniumServer server; private Selenium selenium; }

public void start() {
try {
Properties properties = new Properties();
properties.load(new FileInputStream(getClass().getClassLoader().getResource(“”).getFile()));

String[] serverOptions = Commandline.translateCommandline((String) properties.get(“selenium.server.options”));
RemoteControlConfiguration serverConfiguration = RemoteControlLauncher.parseLauncherOptions(serverOptions);
String browserLauncher = (String) properties.get(“selenium.browserLauncher”);
String browserURL = (String) properties.get(“selenium.browserURL”);

server = new SeleniumServer(serverConfiguration);

selenium = new DefaultSelenium(“localhost”, serverConfiguration.getPort(), browserLauncher, browserURL);

} catch (Exception e) {
throw new RuntimeException(e);

public void stop() {
try {
if (selenium != null) {
} finally {
if (server != null) {

public Selenium geSelenium() {
return selenium;

Step 3
We now need to remove any bean definitions with id=”seleniumFactory” and id=”selenium” from the applicationContext-suite.xml file.
You will have to manually edit, the “applicationContext-suite.xml” of the twist project, and add the following bean definitions.

Step 4
The workflows will now have to depend on the Selenium interface.

For example,
public NewWorkflow(Selenium selenium) {
this.selenium = selenium;

With the above changes, your scenarios will be now use the selenium server and driver jars included in “step a”.


The selenium options are not the same between releases. The beta-2 release of Selenium RC contains some significant changes you should be aware of. You will need to account for these and change these values in “” as required.

For example:

selenium 0.9.2 config : selenium.browserLauncher = *firefox
selenium 1.o Beta 2 config : selenium.browserLauncher = *firefoxproxy

selenium 0.9.2 config : selenium.server.options = -port 4545 -avoidProxy
selenium 1.o Beta 2 config : selenium.server.options = -port 4545 -avoidProxy -honor-system-proxy -singleWindow

For a full list of the changes take a look at

Please Leave a Reply