Intro to Selenium 2 with IDE

Selenium 2 brings many improvements to the Selenium Suite of tools. The quickest way to get started is to download this plug in to Firefox for Selenium IDE web backed formatters. This will allow you to change to format to WebDriver and save the test code into your jUnit or nUnit test suite.

Within the IDE of you choice such as Eclipse or NetBeans edit your project to add the Selenium 2 dependent libraries and selenium-java-2.0b3.jar. The zip file you need on the download page. Or go directly.

This is using the web backed selenium driver which will use the Selenium 1 commands. Once your old tests are working they can be converted to WebDriver type commands. Currently WebDriver does not support all browsers such as Safari so using this emulator mode might be best way to run WebDriver.

By using WebDriver you will not have to start the Selenium Server before running tests. In addition, WebDriver tests do not work by controlling the browser with Javascript. Selenium RC would always want to modify the proxy settings of the browser to enable operation. If your administrator has locked out the ability to modify proxy settings it was impossible to run tests against remote applications. Selenium 2 is a way around this. There should also be additional benefits when testing SSL enabled applications.

If you wish to run the tests using jUnit or have written your tests using the SeleneseTestCase class you must extend your test class. In addition you will have to add the old selenium-java-client-driver.jar file to the project. If you do not use SeleneseTestCase just extend jUnit TestCase.

For more information see

The tests will end up looking like the code below.

package com.example.tests;

import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;
import org.openqa.selenium.*;
import org.openqa.selenium.htmlunit.*;
import org.openqa.selenium.firefox.*;
import org.junit.*;
import static org.junit.Assert.*;

public class webDriverTest extends SeleneseTestCase {
WebDriver driver;
Selenium selenium;

public void setUp() {
  driver = new FirefoxDriver();
  selenium = new WebDriverBackedSelenium(driver,””);

public void tearDown() {

public void testUntitled() {“/”);“//div[@id=’topnav’]/ul/li[4]/a/span”);
  assertEquals(“$1200”, selenium.getText(“//div[@id=’twocol-col2′]/div[2]/h5[5]”));

I hope this helps you out in converting over to Selenium 2.

© Copyright 2012 LMN Solutions

If you  have a question e-mail us or add a comment.


LMN Solutions – Find out more about us.
Leave Yours +

No Comments

Comments are closed.

  • Comments are Closed