【发布时间】:2018-08-16 07:09:33
【问题描述】:
我正在尝试应用拖放功能。它既没有给我错误也没有工作。框的 XPath(我需要拖放)是正确的,我可以点击它。请建议 enter image description here
【问题讨论】:
-
必须提供HTML和试用码
我正在尝试应用拖放功能。它既没有给我错误也没有工作。框的 XPath(我需要拖放)是正确的,我可以点击它。请建议 enter image description here
【问题讨论】:
首先,你的问题没有 Html,我给出的答案是通用的
public static void main(String[] args) throws Exception {
driver.get(URL you want to hit);
//Element which needs to drag.
WebElement FromElem=driver.findElement("Locator"));
//Element on which need to drop.
WebElement ToElem=driver.findElement("Locator"));
//Using Action class for drag and drop.
Actions act=new Actions(driver);
//Dragged and dropped.
act.dragAndDrop(FromElem, ToElem).build().perform();
}
【讨论】: