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 – working with Internet Explorer

In this section we are going to get the text of the element on the page. This is something that most people have to do to check that the right things are happening on the page.

We will need to instantiate InternetExplorerDriver and the call getText() on the element. Let's get to it.

  1. Update the setUp() method to load InternetExplorerDriver():
    driver = new InternetExplorerDriver();
  2. Now we need to find an element. In this section we will find the link Chapter 4:
    WebElement element = driver.findElement(By.id("bid"));
  3. Now we need to get the text of the element:
    element.getText();
  4. Run your test and it should look like the following:
    public class TestChapter6 { WebDriver driver; @Before public void setUp(){ driver ...

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