Working with FirefoxDriver
Everything we need to use in FirefoxDriver is bundled with the Java client bindings, which we used in Chapter 5, Design Patterns. This makes the driver easy to use.
We will do the basic task of loading the browser and type the following into the page:
- Update the
setUp()
method to loadFirefoxDriver();
.driver = new FirefoxDriver();
- Now we need to find an element. In this section, we will find the one with the
nextBid
ID:WebElement element = driver.findElement(By.id("nextBid"));
- Now we need to type the following line of code into that element:
element.sendKeys("100");
- Run your test and it should look like the following:
import org.openqa.selenium.*; import org.openqa.selenium.firefox.*; import org.testng.annotations.*; public class TestChapter6 { WebDriver driver; @BeforeTest public void setUp(){driver = new FirefoxDriver(); driver.get("http://book.theautomatedtester.co.uk/chapter4"); } @AfterTest public void tearDown...