Appearance
I.hoverOn()
Moves the mouse cursor to hover over an element or position.
Usage
javascript
// hover over an element at its center
I.hoverOn(element: string);
// hover over a position relative to the top-left corner of an element
I.hoverOn(element, x: number, y: number);
// hover over a position relative to the top-left corner of the viewport
I.hoverOn(x: number, y: number);Parameters
| Parameter | Type | Description |
|---|---|---|
element | string | The element to hover on — by text, CSS, or XPath selector |
x | number | Horizontal offset in pixels from the left edge of the element or viewport |
y | number | Vertical offset in pixels from the top edge of the element or viewport |
Examples
Hover using text
javascript
I.hoverOn("Help");Hover over an element that best matches the text “Help” (case-insensitive).
This uses the same targeting heuristics as I.click.
Hover using CSS
javascript
I.hoverOn("#menu");Hover over an element that matches the CSS selector #menu.
Hover using XPath
javascript
I.hoverOn("//img[@class='question-mark']");Hover over an element that matches the XPath selector //img[@class='question-mark'].
Hover with element offset
javascript
I.hoverOn("#menu", 100, 10);Hover at an offset of 100px to the right and 10px down from the element’s top-left corner.
Hover at viewport position
javascript
I.hoverOn(300, 500);Hover at the position 300 pixels right and 500 pixels down from the top-left corner of the viewport.