简体   繁体   English

Selenium Webdriver拖放不起作用(Java)

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

what I want to do is to drag a element in the left sidebar to the center area, as shown in the image. 我想要做的是将左侧边栏中的一个元素拖到中心区域,如图所示。 But not working, although no error message show up. 但是,尽管没有出现错误消息,但仍无法正常工作。 image of the page My code is: //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(); //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();

Thanks in advance! 提前致谢!

您也可以尝试以下方法:

(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