Actions action= new Actions(driver);
Action dragAnddrop = action.clickAndHold(SourceItem)
.moveToElement(Destination)
.release(Destination)
.build();
dragAnddrop.perform();
但是此代码给了我以下错误。
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (472, 9041)
如何解决此问题?
答案 0 :(得分:0)
您可能必须等待预期状况中的ElementIsClickable
,像这样:
WebDriverWait wdWait = new WebDriverWait(driver, 10);
wdWait.until(ExpectedConditions.elementToBeClickable(element));
然后从Action
中执行代码。
编辑
对于Action
,您也不需要第二个变量-dragAnddrop
。 Java
的{{1}}实现也执行perform()
,因此也可以跳过。
尝试一下:
build()
我完全忘记了有一种特定的方法。您可能需要在new WebDriverWait(driver, 10)
.until(ExpectedConditions
.elementToBeClickable(SourceItem));
new Actions(driver)
.dragAndDrop(SourceItem, Destination)
.perform();
之前加入前面提到的内容,但是此代码应该可以正常工作。