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 – doing a context click

If you are working in a document editor online or in an e-mail client and you are required to load a context menu, this will be useful. This can also be useful to load other bits of functionality or access specific pages.

To do this we will have to do the following:

  1. Open up inteliij and create a new Selenium WebDriver project.
  2. Create a new class and a new test with the following code:
    WebDriver driver = new FirefoxDriver();ester.co.uk/demo1.html");
    Actions builder = new Actions(driver);
    WebElement element = driver.findElement(By.tagName("body"));
    Action contextClick = builder.contextClick(element)
      .build();
    
    contextClick.perform();
  3. Run the test. You should see the following:

What just happened?

We have managed ...

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