O'Reilly logo

Selenium Testing Tools Cookbook by Unmesh Gundecha

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

Performing drag-and-drop operations

Selenium WebDriver implements Selenium RC's dragAndDrop command using Actions class. As seen in earlier recipes the Actions class supports advanced user interactions such as firing various mouse and keyboard events. We can build simple or complex chains of events using this class.

In this recipe, we will use the Actions class to perform drag-and-drop operations.

How to do it...

Let's implement a test which will perform a drag-and-drop operation on a page using the Actions class.

@Test public void testDragDrop() { driver.get("http://dl.dropbox.com/u/55228056/DragDropDemo.html"); WebElement source = driver.findElement(By.id("draggable")); WebElement target = driver.findElement(By.id("droppable")); Actions builder ...

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