我正在使用selenium chromedriver进行拖放功能。但遗憾的是无法实现它。我正在使用以下代码,
public void dragAndDropElement() {
try {
WebElement imgToDrag = driver.findElement(By
.className("imageclassname"));
WebElement dropHere = driver.findElement(By.cssSelector("panelcssname"));
Actions action = new Actions(driver);
Actions actions = null, movetoElement = null;
actions = action.clickAndHold(imgToDrag);
Thread.sleep(3000);
movetoElement = actions.moveToElement(dropHere);
movetoElement.perform();
movetoElement.release();
Thread.sleep(6000);
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception occured in DragAndDropClass :: dragAndDropElement()", e);
}
}
运行此代码后,没有任何事情发生,我的意思是它既没有抛出任何异常,也没有执行拖放功能。我在这里犯了什么错误,任何人都可以帮助我摆脱这个问题。