How to perform Drag and Drop using selenium webdriver action builder?
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Action; import org.openqa.selenium.interactions.Actions; public class TestActionsForDragNDrop { public static void main(String[] args) throws InterruptedException { WebDriver myTestDriver = new FirefoxDriver(); myTestDriver.manage().window().maximize(); myTestDriver.get("http://tinyurl.com/cslquk"); Actions builder = new Actions(myTestDriver); WebElement man = myTestDriver.findElement(By.xpath("//*[@id='recordsArray_2']")); WebElement Des = myTestDriver.findElement(By.xpath("//*[@id='recordsArray_3']")); Action dragAndDrop = builder.clickAndHold(man).moveToElement(Des).release(Des).build(); Thread.sleep(50000L); dragAndDrop.perform(); myTestDriver.quit(); } }
You must be logged in to post a comment.