moveTo method Null safety

void moveTo(
  1. {WebElement? element,
  2. int? xOffset,
  3. int? yOffset,
  4. bool absolute = false}

Move the mouse.

If absolute is set to true, will move the mouse to the offset relative to web page's top left corner. This is only supported in W3C webdriver.

If element is specified and xOffset and yOffset are not, will move the mouse to the center of the element.

If xOffset and yOffset are specified, will move the mouse that distance from its current location.

If all three are specified, the behavior will be different for W3C and JsonWire. For W3C, it will use element center as the origin, while for JsonWire, it will use element top left corner. To get a consistent behavior across browsers, you can try moveToElementCenter and moveToElementTopLeft to specify the origin you would like to use.

All other combinations of parameters are illegal.

Special notes for W3C, if the destination is out of the current viewport, an 'MoveTargetOutOfBounds' exception will be thrown.


void moveTo(
    {WebElement? element,
    int? xOffset,
    int? yOffset,
    bool absolute = false}) {
          elementId: element?.id,
          xOffset: xOffset,
          yOffset: yOffset,
          absolute: absolute),