- Advertisement -
Selenium provides the Actions class perform certain actions which are not posible using simple selenium commands. in this post we will look one of those action. we will write a code to drag and drop the elements from section to other using Actions class.
lets write a code to implement the drag and drop actions.
public void dragDrop() {
- Advertisement -
driver.get ("url name"); WebElement Source = driver.findelement(By.xpath("xpath or path of element which you want to drag FROM"));
WebElement target= driver.findelement(By.xpath("xpath or path of element which you want to drag TO"));
Actions builder = new Actions(driver); builder.dragAndDrop(source, target).perform(); try { asserts.Equals("Dropped!", Target.getText()); } catch(error e) { verificationErrors.append(e.toString()); }
}