I am writing demo tests for the following drag and drop functionality.[Refer attached Screenshot] For that I have written following code:
@Test
public void DragAndDropTest() {
commonSteps();
WebElement drag = driver.findElement(By.xpath("html/body/div[1]/div[3]/div[2]/div[1]/div[4]/div[3]/div[1]/div[1]/div/div[1]"));
WebElement drop = driver.findElement(By.xpath("html/body/div[1]/div[3]/div[2]/div[1]/div[4]/div[3]/div[1]/div[2]/div/div[1]"));
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(drag).moveToElement(drop).release(drop).build();
dragAndDrop.perform();
}
Webelement drag is for "Right Now" & WebElement drop is for "Quick Press".
My code is able to find these elements, but does not drag and drop "Right Now" frame to "Quick Press" frame.
Also I tried to click on drag, but click is also not working on it. I think these are collapsible drag and drop panels of JQuery. So How to handle collapsible drag and drops using webdriver.
What changes should I make in the code to achieve this?
Actions builder = new Actions(driver);
builder.clickAndHold(drag).moveToElement(drop).build();
builder.dragAndDrop(drag, drop).perform();
This worked for me.