Skip to main content

moveTo

Overview

Use the moveTo command to move the mouse by specified offsets along the X and Y axes relative to the specified element.

If no element is specified, the movement will be executed relative to the current mouse cursor position. If an element is specified and no offsets are provided, the mouse will move to the center of the element. If the element is not visible, it will scroll into view.

Usage

await browser.$(selector).moveTo({ xOffset, yOffset });

Command Parameters

NameTypeDescription
xOffsetNumber

The X-axis offset relative to the middle of the element. If not specified, the mouse will move to the middle of the element.

yOffsetNumber

The Y-axis offset relative to the middle of the element. If not specified, the mouse will move to the middle of the element.

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.