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 – starting Opera

In this section, we will see how we can start OperaDriver and get it to click a button on the page. This simple test will give us the confidence to use Selenium WebDriver with Opera.

  1. Update the setUp() method to load the OperaDriver():
    driver = new OperaDriver();
  2. Now we need to find an element. In this section we will find the link Chapter 4:
    WebElement element = driver.findElement(By.linkText("Chapter 4"));
  3. Now we need to click on the link:
    element.click();
  4. Run your test and it should look like the following:
    public class TestChapter6 {
    
      WebDriver driver;
    
      @Before
      public void setUp(){
        driver = new OperaDriver();
        driver.get("http://book.theautomatedtester.co.uk/");
    
      } @After public void tearDown(){ driver.quit(); } @Test ...

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