JetBrains / intellij-ui-test-robot

The library allows you to write and execute UI tests among IntelliJ IDEA. You can test your Plugin.

Home Page:https://jetbrains-platform.slack.com/archives/C026SVA9MMM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[help]How Do I Drag the Mouse?

diyangsx opened this issue · comments

I recently upgraded to version 0.11.17 of the tool and wanted to ask how to drag and drop the mouse.

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)  
                    }
                """
        )
    }

thanks