简体   繁体   中英

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();

Thanks in advance!

您也可以尝试以下方法:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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