ExecuteAutomation

Drag and Drop UI control in Selenium

In this post we are going to discuss how we can drag and drop a control in selenium. While working with some of the controls like Web parts or widgets in web applications, we may need to test them how the application behaves while trying to organize web parts by dragging and dropping them in different locations. Hence, this code snippet which we are going to discuss in this post will come very handy to achieve the operation. Here is the application UI, which we are going to code for dragging and dropping the control from one location to another

Figure 1: Drag and Drop control

Here is the code snippet
public static void DragAndDrop(WebDriver driver, WebElement srcElement, WebElement dstElement) {
	Actions action = new Actions(driver);
	action.dragAndDrop(srcElement, dstElement).perform();
}
Here is the complete explanation video of the above code Thanks for reading the post and watching the video !!! Please leave your comments and let me know if there is anything need to be improved in the post. Thanks, Karthik KK