In WebDriver we have different ways for performing DragAndDrop operations.
Following are the possible ways for handling DragAndDrop
METHOD 1:
Please do comment for any queries
Following are the possible ways for handling DragAndDrop
METHOD 1:
METHOD 2:// Create Actions object passing in a WebDriver object Actions builder = new Actions(driver); // Chain some calls together and call build Action dragAndDrop = builder.clickAndHold(someElement) .moveToElement(otherElement) .release(otherElement) .build(); // Perform the actions dragAndDrop.perform();
METHOD 3:WebElement source = driver.findElement(By.id("draggable")); WebElement target = driver.findElement(By.id("droppable")); Actions builder = new Actions(driver); builder.dragAndDrop(source, target).perform(); try{ assertEquals("Dropped!", target.getText()); } catch (Error e) { verificationErrors.append(e.toString()); }
Actions builder = new Actions(driver); builder.clickAndHold(SOURCEELEMENT) .moveByOffset(10, 50).release().perform();
METHOD 4:
Action dragAndDrop = builder.dragAndDropBy(SourceElement, 10, 20) .build(); dragAndDrop.perform();