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 – loading the FirefoxDriver

We are going to do the basic task of loading the browser and type into the page.

  1. Update the setUp() method to load the FirefoxDriver();
    driver = new FirefoxDriver();
  2. Now we need to find an element. In this section we will find the one with the ID nextBid:
    WebElement element = driver.findElement(By.id("nextBid"));
  3. Now we need to type into that element:
    element.sendKeys("100");
  4. Run your test and it should look like the following:
    public class TestChapter6 { WebDriver driver; @Before public void setUp(){driver = new FirefoxDriver(); driver.get("http://book.theautomatedtester.co.uk/chapter4"); } @After public void tearDown(){ driver.quit(); } @Test public void testExamples(){ WebElement element = driver.findElement(By.id("nextBid")); ...

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