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

Actions

The Actions class allows us to build a chain of actions that we would like to perform. This means that we can build up a nice sequence, for example "Press Shift and type and then release", or if we wanted to work with a select that allows multiple selects, we could press Shift and then do the necessary clicks.

We do this by creating an Actions object. We then need to chain some calls together:

// Create Actions object passing in a WebDriver object
Actions builder = new Actions(driver);

// Chain some calls together and call build
Action dragAndDrop = builder.clickAndHold(someElement)
  .moveToElement(otherElement)
  .release(otherElement)
  .build();

// Perform the actions
dragAndDrop.perform();

Drag and drop

We have seen that drag and drop is one ...

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