3030import java .util .Set ;
3131import java .util .function .IntConsumer ;
3232import org .openqa .selenium .Keys ;
33+ import org .openqa .selenium .Point ;
3334import org .openqa .selenium .WebDriver ;
3435import org .openqa .selenium .WebElement ;
3536import org .openqa .selenium .interactions .PointerInput .Origin ;
@@ -352,9 +353,9 @@ private Actions moveInTicks(WebElement target, int xOffset, int yOffset) {
352353 }
353354
354355 /**
355- * Moves the mouse from its current position (or 0,0) by the given offset. If the coordinates
356- * provided are outside the viewport (the mouse will end up outside the browser window) then the
357- * viewport is scrolled to match .
356+ * Moves the mouse from its current position (or 0,0) by the given offset. If the final
357+ * coordinates of the move are outside the viewport (the mouse will end up outside the browser window),
358+ * an exception is raised .
358359 *
359360 * @param xOffset horizontal offset. A negative value means moving the mouse left.
360361 * @param yOffset vertical offset. A negative value means moving the mouse up.
@@ -368,6 +369,24 @@ public Actions moveByOffset(int xOffset, int yOffset) {
368369 .createPointerMove (Duration .ofMillis (200 ), Origin .pointer (), xOffset , yOffset ));
369370 }
370371
372+ /**
373+ * Moves the mouse to provided coordinates on screen regardless of starting position of
374+ * the mouse. If the coordinates
375+ * provided are outside the viewport (the mouse will end up outside the browser window),
376+ * an exception is raised.
377+ *
378+ * @param xCoordinate positive pixel value along horizontal axis in viewport. Numbers increase going right.
379+ * @param yCoordinate positive pixel value along vertical axis in viewport. Numbers increase going down.
380+ * @return A self reference.
381+ * @throws MoveTargetOutOfBoundsException if the provided offset is outside the document's
382+ * boundaries.
383+ */
384+ public Actions moveToLocation (int xCoordinate , int yCoordinate ) {
385+ return tick (
386+ getActivePointer ()
387+ .createPointerMove (Duration .ofMillis (250 ), Origin .viewport (), xCoordinate , yCoordinate ));
388+ }
389+
371390 /**
372391 * Performs a context-click at middle of the given element. First performs a mouseMove to the
373392 * location of the element.
0 commit comments