请帮助解决其他动作类..我必须拖放元素;来自元素;到元素'在java中
答案 0 :(得分:0)
我建议您使用'Robot'进行拖放操作。这很直截了当。我如何使用它的一个例子可能对你有用......
// Location of your first element
Point coordinates1 = driver.findElement(By.xpath("your element xpath")).getLocation();
// Location of your second Element
Point coordinates2 = driver.findElement(By.xpath("your element xpath")).getLocation();
Robot robot = new Robot();
robot.setAutoDelay(2000);
robot.setAutoWaitForIdle(true);
// go to the location of the first element
robot.mouseMove(coordinates1.getX(), coordinates1.getY());
robot.delay(500);
// Press the mouse on the first location
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(500);
// Move the mouse to the second location
robot.mouseMove(coordinates2.getX(), coordinates2.getY());
// Release the mouse on the second location
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK)