繁体   English   中英

Selenium Webdriver拖放不起作用(Java)

[英]Selenium webdriver drag and drop not working (java)

我想要做的是将左侧边栏中的一个元素拖到中心区域,如图所示。 但是,尽管没有出现错误消息,但仍无法正常工作。 页面的图像我的代码是: //drag and drop - not working WebElement element = driver.findElement(By.xpath("//*[@id='componentsSection']/div[1]/div[1]")); Thread.sleep(1000); WebElement target = driver.findElement(By.id("layoutSection")); Thread.sleep(1000); (new Actions(driver)).dragAndDrop(element, target).build().perform(); //drag and drop - not working WebElement element = driver.findElement(By.xpath("//*[@id='componentsSection']/div[1]/div[1]")); Thread.sleep(1000); WebElement target = driver.findElement(By.id("layoutSection")); Thread.sleep(1000); (new Actions(driver)).dragAndDrop(element, target).build().perform();

提前致谢!

您也可以尝试以下方法:

(new Actions(driver)).clickAndHold(element).moveToElement(target).release(element).build().perform();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM