O'Reilly logo

Selenium 2 Testing Tools Beginner's Guide by David Burns

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – converting tests to Selenium WebDriver using WebDriverBackedSelenium

Let's take one of our Selenium Remote Control tests and change it to use WebDriverBackedSelenium. This should be a simple change:

import com.thoughtworks.selenium.*;
import org.junit.*;

public class TestSeleniumWebDriver { // We can name this file what we want

  Selenium selenium;

  @Before
  public void setup(){
    selenium = new DefaultSelenium("localhost",4444,"*chrome","http://book.theautomatedtester.co.uk");
    selenium.start();
  }

  @Test
  public void shouldOpenChapter2LinkAndVerifyAButton(){
    /* This will contain some actions for us. We are going 
    * to be concentrating on the @Before and @After methods
  }

  @After
  public void teardown(){
    selenium.stop();
  }
}
  1. Open IDEA and load ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required