Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automate drag & drop functionality using Selenium WebDriver Java

How to automate drag & drop functionality using Selenium WebDriver in java?

like image 972
user1891145 Avatar asked Jan 08 '13 07:01

user1891145


People also ask

How do you automate dragAndDrop?

Find below the steps of the scenario to be automated: Now Drag and Drop 'Drag me to my target' object to 'Drop Here' object. Verify message displayed on 'Drop Here' to verify that source element is dropped at the target element. Close the browser to end the program.

How do you dragAndDrop in selenium Python?

In our case, we'll use these operations for drag and drop in Selenium Python by simulating click using click_and_hold, then dragging by using move_to_element or move_by_offset or combo, and by finally releasing, i.e., dropping the selected element.


1 Answers

There is a page documenting Advanced User Interactions; which has a lot of great examples on how to generate a sequence of actions, you can find it here

// Configure the action Actions builder = new Actions(driver);  builder.keyDown(Keys.CONTROL)    .click(someElement)    .click(someOtherElement)    .keyUp(Keys.CONTROL);  // Then get the action: Action selectMultiple = builder.build();  // And execute it: selectMultiple.perform();    

or

Actions builder = new Actions(driver);  Action dragAndDrop = builder.clickAndHold(someElement)    .moveToElement(otherElement)    .release(otherElement)    .build();  dragAndDrop.perform(); 
like image 149
r-sal Avatar answered Sep 30 '22 10:09

r-sal