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 OperaProfile

Imagine that you want to test your web application that uses geolocation in the browser, when it cannot use geolocation. All location-based applications need to support this if you were to get a user who is worried about privacy on certain machines.

  1. Update the setUp() method to load the OperaDriver():
    OperaProfile profile = new OperaProfile();
    profile.preferences().set("Geolocation", "Enable geolocation", false);
    driver = new OperaDriver(profile);
  2. Now we need to find an element. In this section we will find the link Chapter 4:
    WebElement element = driver.findElement(By.linkTexxt("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 ...

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