O'Reilly logo

Selenium Essentials by Prashanth Sams

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

Mouse and keyboard actions

In Selenium WebDriver, actions can be either mouse actions or keyboard actions. The selenium-based Actions API provides support to click on a particular location with or without elements and use keyboard shortcuts efficiently.

  • The build() method generates all the composite actions. The following is the syntax for this function:
    action.build();

    The following code snippet explains to you how you can generate actions using the build() method:

    Actions action = new Actions(driver);
    action.click(driver.findElement(By.locatorType("path")));
    action.build();
  • The click() method performs a mouse click on the current mouse pointer location. The following is the syntax for this function:
    action.click(); action.click(driver.findElement(By. ...

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