[help]How Do I Drag the Mouse?
diyangsx opened this issue · comments
diyangsx commented
I recently upgraded to version 0.11.17 of the tool and wanted to ask how to drag and drop the mouse.
eugene nizienko commented
Hi, this is a snipppet we use in out tests
fun dragAndDrop(startPoint: Point, endPoint: Point) = step("Drag and Drop from $startPoint to $endPoint") {
remoteRobot.runJs(
"""
const pointStart = new Point(${startPoint.x}, ${startPoint.y})
const pointEnd = new Point(${endPoint.x}, ${endPoint.y})
try {
robot.moveMouse(pointStart)
Thread.sleep(300)
robot.pressMouse(MouseButton.LEFT_BUTTON)
Thread.sleep(500)
robot.moveMouse(pointEnd)
} finally {
Thread.sleep(500)
robot.releaseMouse(MouseButton.LEFT_BUTTON)
}
"""
)
}
diyangsx commented
thanks