Class RobotsMouse

java.lang.Object
com.workfusion.rpa.helpers.RobotsMouse
All Implemented Interfaces:
org.openqa.selenium.interactions.Mouse

public class RobotsMouse extends Object implements org.openqa.selenium.interactions.Mouse
Wraps original driver's Mouse and provides additional simplified methods like:

Driver model

This class wraps the Mouse of the RPA Driver, which is itself a façade over the real automation backend — either a Selenium 4 based Web driver (browser), a native Desktop driver (desktop application UI), or a Universal driver supporting both. The (x, y) actions therefore are not inherently browser actions: depending on the active backend the same call may move a real OS cursor on the desktop or a pointer inside a browser viewport. Each method simply delegates to the wrapped Mouse, so the actual interpretation of the coordinates is decided by that underlying backend.

Coordinate system

The (x, y) overloads (for example click(int, int), mouseMove(int, int)) address an absolute point, wrapped in a PointedCoordinates, where (0, 0) is the top-left of the screen (Desktop) or of the document (Web). These are raw point coordinates, not element-relative offsets: to click relative to an element's top-left corner, use the offset-based methods on UiElement (e.g. UiElement.click(int, int)), which convert a top-left offset into the element-center offset expected by the Selenium 4 Actions API.

Samples
mouse().click(300, 200); — left-click the absolute point x=300, y=200 (screen pixels on Desktop, document pixels on Web).
mouse().doubleClick(300, 200); — double-click the same absolute point.
mouse().contextClick(300, 200); — right-click to open a context menu at that point.
// Drag from (100, 100) to (400, 250) by holding the left button:
 mouse().mouseDown(100, 100)
        .mouseMove(400, 250)
        .mouseUp(400, 250);
mouse().mouseMove(100, 100, 50, 20); — move to (100, 100) then shift by (50, 20), ending at the absolute point (150, 120).
  • Constructor Summary

    Constructors
    Constructor
    Description
    RobotsMouse(org.openqa.selenium.interactions.Mouse mouse)
    Wraps driver's mouse to use simplified RPA methods on it
  • Method Summary

    Modifier and Type
    Method
    Description
    click(int x, int y)
    Left-clicks the absolute point specified by coordinates.
    click(int clicks, int x, int y)
    Left-clicks clicks times on the absolute point specified by coordinates.
    void
    click(org.openqa.selenium.interactions.Coordinates where)
    Left-clicks once at the given coordinates, delegating to the wrapped driver's Mouse.
    void
    click(org.openqa.selenium.interactions.Coordinates coordinates, int clicks)
    Left-clicks clicks times at the given coordinates (all clicks at the same point), delegating to the wrapped driver's Mouse.
    contextClick(int x, int y)
    Right-clicks (context-clicks) the absolute point specified by coordinates.
    void
    contextClick(org.openqa.selenium.interactions.Coordinates where)
    Right-clicks (context-clicks) once at the given coordinates, delegating to the wrapped driver's Mouse.
    doubleClick(int x, int y)
    Double-clicks the absolute point specified by coordinates.
    void
    doubleClick(org.openqa.selenium.interactions.Coordinates where)
    Double-clicks (two left clicks) at the given coordinates, delegating to the wrapped driver's Mouse.
    boolean
    Compares this wrapper with another by reflectively comparing their fields (the wrapped mouse).
    int
     
    mouseDown(int x, int y)
    Presses the left button down (without releasing it) at the absolute point specified by coordinates.
    void
    mouseDown(org.openqa.selenium.interactions.Coordinates where)
    Presses the left button down (without releasing it) at the given coordinates, delegating to the wrapped driver's Mouse.
    mouseMove(int x, int y)
    Moves the mouse cursor to the absolute point specified by coordinates (no button press).
    mouseMove(int x, int y, int xOffset, int yOffset)
    Moves the mouse cursor to an absolute base point and then shifts it by an additional offset.
    void
    mouseMove(org.openqa.selenium.interactions.Coordinates where)
    Moves the mouse cursor to the given coordinates (no button press), delegating to the wrapped driver's Mouse.
    void
    mouseMove(org.openqa.selenium.interactions.Coordinates where, long xOffset, long yOffset)
    Moves the mouse cursor to a base point and then shifts it by an additional offset; the final position is where + (xOffset, yOffset).
    mouseUp(int x, int y)
    Releases the left button at the absolute point specified by coordinates.
    void
    mouseUp(org.openqa.selenium.interactions.Coordinates where)
    Releases the left button at the given coordinates, delegating to the wrapped driver's Mouse.
    tripleClick(int x, int y)
    Triple-clicks the absolute point specified by coordinates.
    void
    tripleClick(org.openqa.selenium.interactions.Coordinates where)
    Triple-clicks (three left clicks) at the given coordinates, delegating to the wrapped driver's Mouse.
    wheelClick(int x, int y)
    Middle-button (wheel) clicks the absolute point specified by coordinates.
    void
    wheelClick(org.openqa.selenium.interactions.Coordinates where)
    Middle-button (wheel) clicks once at the given coordinates, delegating to the wrapped driver's Mouse.
    void
    wheelDown(int times)
    Scrolls the mouse wheel down at the current cursor position, delegating to the wrapped driver's Mouse.
    void
    wheelUp(int times)
    Scrolls the mouse wheel up at the current cursor position, delegating to the wrapped driver's Mouse.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RobotsMouse

      public RobotsMouse(org.openqa.selenium.interactions.Mouse mouse)
      Wraps driver's mouse to use simplified RPA methods on it
      Parameters:
      mouse - driver's Mouse object
  • Method Details

    • click

      public void click(org.openqa.selenium.interactions.Coordinates where)
      Left-clicks once at the given coordinates, delegating to the wrapped driver's Mouse.

      Driver Type: Desktop, Web

      Specified by:
      click in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      where - target point (see the class-level "Coordinate system" section)
      See Also:
      • Mouse.click(Coordinates)
    • click

      public void click(org.openqa.selenium.interactions.Coordinates coordinates, int clicks)
      Left-clicks clicks times at the given coordinates (all clicks at the same point), delegating to the wrapped driver's Mouse.

      Driver Type: Desktop

      Specified by:
      click in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      coordinates - target point (see the class-level "Coordinate system" section)
      clicks - number of consecutive clicks to perform
      See Also:
      • Mouse.click(Coordinates, int)
    • doubleClick

      public void doubleClick(org.openqa.selenium.interactions.Coordinates where)
      Double-clicks (two left clicks) at the given coordinates, delegating to the wrapped driver's Mouse.

      Driver Type: Desktop, Web

      Specified by:
      doubleClick in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      where - target point (see the class-level "Coordinate system" section)
      See Also:
      • Mouse.doubleClick(Coordinates)
    • tripleClick

      public void tripleClick(org.openqa.selenium.interactions.Coordinates where)
      Triple-clicks (three left clicks) at the given coordinates, delegating to the wrapped driver's Mouse.

      Driver Type: Desktop

      Specified by:
      tripleClick in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      where - target point (see the class-level "Coordinate system" section)
      See Also:
      • Mouse.tripleClick(Coordinates)
    • mouseDown

      public void mouseDown(org.openqa.selenium.interactions.Coordinates where)
      Presses the left button down (without releasing it) at the given coordinates, delegating to the wrapped driver's Mouse. Pair with mouseUp(Coordinates) for drag-and-drop.

      Driver Type: Desktop, Web

      Specified by:
      mouseDown in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      where - target point (see the class-level "Coordinate system" section)
      See Also:
      • Mouse.mouseDown(Coordinates)
    • mouseUp

      public void mouseUp(org.openqa.selenium.interactions.Coordinates where)
      Releases the left button at the given coordinates, delegating to the wrapped driver's Mouse. Typically used after mouseDown(Coordinates).

      Driver Type: Desktop, Web

      Specified by:
      mouseUp in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      where - target point (see the class-level "Coordinate system" section)
      See Also:
      • Mouse.mouseUp(Coordinates)
    • mouseMove

      public void mouseMove(org.openqa.selenium.interactions.Coordinates where)
      Moves the mouse cursor to the given coordinates (no button press), delegating to the wrapped driver's Mouse.

      Driver Type: Desktop, Web

      Specified by:
      mouseMove in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      where - target point (see the class-level "Coordinate system" section)
      See Also:
      • Mouse.mouseMove(Coordinates)
    • mouseMove

      public void mouseMove(org.openqa.selenium.interactions.Coordinates where, long xOffset, long yOffset)
      Moves the mouse cursor to a base point and then shifts it by an additional offset; the final position is where + (xOffset, yOffset). Delegates to the wrapped driver's Mouse.

      Driver Type: Desktop, Web

      Specified by:
      mouseMove in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      where - base target point (see the class-level "Coordinate system" section)
      xOffset - additional horizontal offset from the base point, in pixels (grows to the right)
      yOffset - additional vertical offset from the base point, in pixels (grows downward)
      See Also:
      • Mouse.mouseMove(Coordinates, long, long)
    • contextClick

      public void contextClick(org.openqa.selenium.interactions.Coordinates where)
      Right-clicks (context-clicks) once at the given coordinates, delegating to the wrapped driver's Mouse.

      Driver Type: Desktop, Web

      Specified by:
      contextClick in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      where - target point (see the class-level "Coordinate system" section)
      See Also:
      • Mouse.contextClick(Coordinates)
    • wheelClick

      public void wheelClick(org.openqa.selenium.interactions.Coordinates where)
      Middle-button (wheel) clicks once at the given coordinates, delegating to the wrapped driver's Mouse.

      Driver Type: Desktop

      Specified by:
      wheelClick in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      where - target point (see the class-level "Coordinate system" section)
      See Also:
      • Mouse.wheelClick(Coordinates)
    • wheelUp

      public void wheelUp(int times)
      Scrolls the mouse wheel up at the current cursor position, delegating to the wrapped driver's Mouse.

      Driver Type: Desktop

      Specified by:
      wheelUp in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      times - number of wheel ticks to scroll up
      See Also:
      • Mouse.wheelUp(int)
    • wheelDown

      public void wheelDown(int times)
      Scrolls the mouse wheel down at the current cursor position, delegating to the wrapped driver's Mouse.

      Driver Type: Desktop

      Specified by:
      wheelDown in interface org.openqa.selenium.interactions.Mouse
      Parameters:
      times - number of wheel ticks to scroll down
      See Also:
      • Mouse.wheelDown(int)
    • click

      public RobotsMouse click(int x, int y)
      Left-clicks the absolute point specified by coordinates.

      Coordinates are absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section.

      Driver Type: Desktop, Web

      Parameters:
      x - absolute x coordinate, in pixels
      y - absolute y coordinate, in pixels
      Returns:
      instance of RobotsMouse
    • click

      public RobotsMouse click(int clicks, int x, int y)
      Left-clicks clicks times on the absolute point specified by coordinates.

      Coordinates are absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section.

      Driver Type: Desktop

      Parameters:
      clicks - number of consecutive clicks to perform
      x - absolute x coordinate, in pixels
      y - absolute y coordinate, in pixels
      Returns:
      instance of RobotsMouse
    • doubleClick

      public RobotsMouse doubleClick(int x, int y)
      Double-clicks the absolute point specified by coordinates.

      Coordinates are absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section.

      Driver Type: Desktop, Web

      Parameters:
      x - absolute x coordinate, in pixels
      y - absolute y coordinate, in pixels
      Returns:
      instance of RobotsMouse
    • tripleClick

      public RobotsMouse tripleClick(int x, int y)
      Triple-clicks the absolute point specified by coordinates.

      Coordinates are absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section.

      Driver Type: Desktop

      Parameters:
      x - absolute x coordinate, in pixels
      y - absolute y coordinate, in pixels
      Returns:
      instance of RobotsMouse
    • wheelClick

      public RobotsMouse wheelClick(int x, int y)
      Middle-button (wheel) clicks the absolute point specified by coordinates.

      Coordinates are absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section.

      Driver Type: Desktop

      Parameters:
      x - absolute x coordinate, in pixels
      y - absolute y coordinate, in pixels
      Returns:
      instance of RobotsMouse
    • mouseDown

      public RobotsMouse mouseDown(int x, int y)
      Presses the left button down (without releasing it) at the absolute point specified by coordinates. Pair with mouseUp(int, int) to implement drag-and-drop.

      Coordinates are absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section.

      Driver Type: Desktop, Web

      Parameters:
      x - absolute x coordinate, in pixels
      y - absolute y coordinate, in pixels
      Returns:
      instance of RobotsMouse
    • mouseUp

      public RobotsMouse mouseUp(int x, int y)
      Releases the left button at the absolute point specified by coordinates. Typically used after mouseDown(int, int).

      Coordinates are absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section.

      Driver Type: Desktop, Web

      Parameters:
      x - absolute x coordinate, in pixels
      y - absolute y coordinate, in pixels
      Returns:
      instance of RobotsMouse
    • mouseMove

      public RobotsMouse mouseMove(int x, int y)
      Moves the mouse cursor to the absolute point specified by coordinates (no button press).

      Coordinates are absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section.

      Driver Type: Desktop, Web

      Parameters:
      x - absolute x coordinate, in pixels
      y - absolute y coordinate, in pixels
      Returns:
      instance of RobotsMouse
    • mouseMove

      public RobotsMouse mouseMove(int x, int y, int xOffset, int yOffset)
      Moves the mouse cursor to an absolute base point and then shifts it by an additional offset. The final position is (x + xOffset, y + yOffset).

      The base point is absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section. The offset is then applied in the same axes (xOffset to the right, yOffset downward).

      Driver Type: Desktop, Web

      Parameters:
      x - absolute base x coordinate, in pixels
      y - absolute base y coordinate, in pixels
      xOffset - additional horizontal offset from the base point, in pixels (grows to the right)
      yOffset - additional vertical offset from the base point, in pixels (grows downward)
      Returns:
      instance of RobotsMouse
    • contextClick

      public RobotsMouse contextClick(int x, int y)
      Right-clicks (context-clicks) the absolute point specified by coordinates.

      Coordinates are absolute (screen pixels on Desktop, document pixels on Web); see the class-level "Coordinate system" section.

      Driver Type: Desktop, Web

      Parameters:
      x - absolute x coordinate, in pixels
      y - absolute y coordinate, in pixels
      Returns:
      instance of RobotsMouse
    • equals

      public boolean equals(Object o)
      Compares this wrapper with another by reflectively comparing their fields (the wrapped mouse).
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with
      Returns:
      true if all fields are equal
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      a hash code derived from the wrapped Mouse