Selenium 无法拖动&;把盒子放进硒里
我正在尝试应用拖放功能。它既不会给我错误,也不会工作。框的XPath(我需要拖放)是正确的,我可以单击它。请建议Selenium 无法拖动&;把盒子放进硒里,selenium,drag-and-drop,Selenium,Drag And Drop,我正在尝试应用拖放功能。它既不会给我错误,也不会工作。框的XPath(我需要拖放)是正确的,我可以单击它。请建议 首先,你的问题没有Html,我给出的答案是通用的 public static void main(String[] args) throws Exception { driver.get(URL you want to hit); //Element which needs to drag. WebElement FromElem=driver.findE
首先,你的问题没有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();
}
必须提供HTML和试用代码