Book Image

Learning Selenium Testing Tools - Third Edition

Book Image

Learning Selenium Testing Tools - Third Edition

Overview of this book

Table of Contents (22 chapters)
Learning Selenium Testing Tools Third Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Actions class


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 something and then release", or if we want to work with a select that allows multiple selects, we can 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 of the main things that people want to do with web applications. This allows them to build task boards that allow other people to drag and drop between different states. You may have seen applications like this if you work...