Class HtmlUnitMouse


  • public class HtmlUnitMouse
    extends Object
    Provides basic mouse interaction support for HtmlUnitDriver.

    This class handles element activation, focus changes, and simple event dispatching needed to emulate mouse behavior within HtmlUnit's DOM model. It is typically used internally by the HtmlUnit-backed WebDriver implementation and is not intended for direct user instantiation.

    Author:
    Simon Stewart, Alexei Barantsev, Ahmed Ashour, Ronald Brill, Martin Bartoš
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void click​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
      Performs a mouse click on the element represented by the given Coordinates.
      void contextClick​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
      Performs a context (right) click on the element identified by the given Coordinates.
      void doubleClick​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
      Performs a double-click action on the element identified by the given Coordinates.
      void mouseDown​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
      Performs a mouse-down (button press) action on the element indicated by the given Coordinates.
      void mouseMove​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
      Moves the mouse cursor to the element referenced by the specified Coordinates.
      void mouseMove​(org.openqa.selenium.interactions.Coordinates where, long xOffset, long yOffset)
      Moves the mouse to the specified coordinates with an additional X/Y offset.
      void mouseUp​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
      Performs a mouse-up (button release) action on the element indicated by the given Coordinates.
    • Method Detail

      • click

        public void click​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
        Performs a mouse click on the element represented by the given Coordinates.

        The coordinates are resolved into the corresponding DomElement, which is then clicked using the parent HtmlUnitDriver. This method triggers the standard HtmlUnit click behavior, including event dispatch and potential navigation.

        Parameters:
        elementCoordinates - the coordinates identifying the target element; may not be null
        Throws:
        org.openqa.selenium.NoSuchElementException - if no corresponding element can be resolved from the provided coordinates
      • doubleClick

        public void doubleClick​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
        Performs a double-click action on the element identified by the given Coordinates. The coordinates are resolved to a DomElement, and the click is forwarded to the parent HtmlUnitDriver.
        Parameters:
        elementCoordinates - the coordinates representing the target element; must not be null
        Throws:
        org.openqa.selenium.NoSuchElementException - if no corresponding element can be resolved
      • contextClick

        public void contextClick​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
        Performs a context (right) click on the element identified by the given Coordinates. The element is resolved and then interacted with using HtmlUnit’s right-click event dispatch.
        Parameters:
        elementCoordinates - the coordinates of the element to right-click; must not be null
      • mouseDown

        public void mouseDown​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
        Performs a mouse-down (button press) action on the element indicated by the given Coordinates. The resolved element is forwarded to the driver for processing.
        Parameters:
        elementCoordinates - the coordinates identifying the target element; must not be null
      • mouseUp

        public void mouseUp​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
        Performs a mouse-up (button release) action on the element indicated by the given Coordinates. The resolved element is delegated to the driver for handling.
        Parameters:
        elementCoordinates - the coordinates identifying the target element; must not be null
      • mouseMove

        public void mouseMove​(org.openqa.selenium.interactions.Coordinates elementCoordinates)
        Moves the mouse cursor to the element referenced by the specified Coordinates. The element is obtained from the coordinates and delegated to the driver.
        Parameters:
        elementCoordinates - the coordinates whose auxiliary object identifies the target element; must not be null
      • mouseMove

        public void mouseMove​(org.openqa.selenium.interactions.Coordinates where,
                              long xOffset,
                              long yOffset)
        Moves the mouse to the specified coordinates with an additional X/Y offset.

        HtmlUnit does not support arbitrary coordinate-based mouse positioning, so this operation is not available.

        Parameters:
        where - the base coordinates; ignored
        xOffset - the horizontal offset; ignored
        yOffset - the vertical offset; ignored
        Throws:
        UnsupportedOperationException - always, as coordinate-based movement is not supported