• tahseenat

Drag & Drop Items

In some applications, we may face a situation to automate drag and drop an item from one location to another location. We could not achieve these using basic elements. Selenium has provided an “Actions” class to handle this kind of scenario. We overcome this kind of scenarios such as drag and drop using Actions Class.


package wizdomqa;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.interactions.Actions;

import org.openqa.selenium.support.ui.ExpectedConditions;

import org.openqa.selenium.support.ui.WebDriverWait;

import org.testng.annotations.Test;

public class ActionsClass {


public void actionsClass() throws InterruptedException{

System.setProperty("webdriver.chrome.driver", "C:\\Selenium Environment\\Drivers\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

//Create an object 'action'

Actions action = new Actions(driver);

//navigate to the required url where we could do drag and drop action


//WebdriverWait is used to wait for a frame to be available. Once it is availble we switch to the frame to achieve our task

WebDriverWait wait = new WebDriverWait(driver, 5);


//To get source locator

WebElement sourceLocator =driver.findElement(By.cssSelector("#draggable"));

//To get target locator

WebElement targetLocator =driver.findElement(By.cssSelector("#droppable"));

//dragAndDrop(source, target) method accepts two parameters source and locator.

//used dragAndDrop method to drag and drop the source locator to target locator

action.dragAndDrop(sourceLocator, targetLocator).build().perform();



Wizdom QA has created an end to end course curriculum for the SDET profile. Our students will receive in-depth knowledge of the latest QA tools, techniques and programming languages.

As a registered student, you will learn Selenium WebDriver, Appium for Mobile App automation, API automation, CI/CD integration and many more.

We have studied the market carefully and understood that there is a huge demand for good SDET profiles, however, finding the right candidate is quite hard because of the lack of right skills and experience among job seekers.


Therefore we are here with 11+ years of hands-on and training 800+ students to experience to create one-stop-shop course content for Software Development Engineering in Test (SDETs).


Belgard Square West, Tallaght,

Dublin, Ireland

Phone & WhatsApp

+353 894740999




Additional Links

Wizdom QA Trainings | All rights reserved | 2019-20 ©

  • Facebook Social Icon