Drag and Drop is not working in my selenium code below, can anyone help me?
package selenium;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.Bas
Few things I observed in your code that
You need to first replace
WebElement from= driver.findElementByXPath("html/body/div[1]");
with
WebElement from = driver.findElement(By.xpath("html/body/div[1]"))
And
WebElement to=driver.findElementByXPath("html/body/div[2]");
with
WebElement to = driver.findElement(By.xpath("html/body/div[2]"));
You can use following code to work out:
driver.navigate().to("http://jqueryui.com/droppable/");
//Wait for the frame to be available and switch to it
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector(".demo-frame")));
WebElement Sourcelocator = driver.findElement(By.cssSelector(".ui-draggable"));
WebElement Destinationlocator = driver.findElement(By.cssSelector(".ui-droppable"));
dragAndDrop(Sourcelocator,Destinationlocator);