【发布时间】:2021-04-09 03:49:49
【问题描述】:
我正在尝试将一个元素(//li[text()='Rel_ME_Hotfix'])拖到目标 web 元素(//div[@id='dropEventDataId0'])中。下面是我试过的代码。
Actions act=new Actions(driver);
WebElement source=driver.findElement(By.xpath("//li[text()=' Rel_ME_Hotfix ']"));
WebElement destination=driver.findElement(By.xpath("//div[@id='dropEventDataId0']"));
act.clickAndHold(source).pause(2000).moveToElement(destination).release().build().perform();
也试过
Actions action = new Actions(driver);
WebElement From = driver.findElement(from);
WebElement To = driver.findElement(to);
action.dragAndDrop(From,To).build().perform();
尝试将目标 web 元素设置为 //div[@id='masterOptionDiv'] 但没有运气。
脚本只是运行,但元素没有被放入目标 web 元素。附上html代码供参考。
【问题讨论】:
标签: selenium-webdriver drag-and-drop