Module org.testfx

Interface RobotAdapter<T>

  • All Known Implementing Classes:
    AwtRobotAdapter, GlassRobotAdapter, JavafxRobotAdapter

    public interface RobotAdapter<T>
    The common interface for all RobotAdapters.
    These are the minimum set of functions required from a robot to provide the full functionality use in the higher level api.

    Threading

    The caller of the Adapter usually doesn't run on the FX-Application Thread. If required, the implementation of this class will schedule the actions on the FX-Application Thread.
    • Method Detail

      • robotCreate

        void robotCreate()
        Creates a robot.
      • robotDestroy

        void robotDestroy()
        Destroys the robot
      • keyPress

        void keyPress​(KeyCode key)
        Function used to make the robot press a key. The key must be a physical existing key on the keyboard.
        Parameters:
        key - the key to press (must exist on a keyboard)
      • keyRelease

        void keyRelease​(KeyCode key)
        Function used to make the robot release a key. The key must be a physical existing key on the keyboard.
        Parameters:
        key - the key to press (must exist on a keyboard)
      • getMouseLocation

        Point2D getMouseLocation()
        Returns the current position of the cursor in JavaFx coordinates
        Returns:
        the current position of the mouse cursor
      • mouseMove

        void mouseMove​(Point2D location)
        Moves the mouse cursor to the given position in JavaFx coordinates
        Parameters:
        location - the location in JavaFx coordinates to move the cursor to
      • mousePress

        void mousePress​(MouseButton button)
        Makes the robot press a mouse button.
        Parameters:
        button - the button to press
      • mouseRelease

        void mouseRelease​(MouseButton button)
        Makes the robot release a mouse button.
        Parameters:
        button - the button to release
      • mouseWheel

        void mouseWheel​(int wheelAmount)
        Makes the robot to simulate a action of the mouse wheel.
        Negative values indicate movement up/away from the user, positive values indicate movement down/towards the user.
        Parameters:
        wheelAmount - the amount to scroll
      • getCapturePixelColor

        Color getCapturePixelColor​(Point2D location)
        Gets the color of a pixel at the given JavaFx coordinates. The returned Color is in the JavaFx color space. //TODO Due to technical reasons, there might be a deviation in color.
        Parameters:
        location - of the pixel in JavaFx coordinates, to retrieve the color for
        Returns:
        the Color of the given Pixel in the JavaFx color space
      • getCaptureRegion

        Image getCaptureRegion​(Rectangle2D region)
        Captures a region of the screen. The returned Image is in the JavaFx color space. //TODO Due to technical reasons, there might be a deviation.
        Parameters:
        region - the region to capture in JavaFx coordinates
        Returns:
        a image of the region