hover(selector [, options])
This is a TDK feature
This is not supported in Testim's visual editor
Hovers over the given element on the screen, on the element center by default.
selector
{string | TDKStepLocator} a CSS selector or smart locator.options
{object} optional extra argumentsoffset
{object}:x
{number} x position in element to hover iny
{number} y position in element to hover in
- returns: Promise which fulfills when the element matching
selector
has been hovered over.
For example:
// ✅ hover on the first H1 in the page
await hover('h1');
// ✅ hover on the first H1 in the page in the given offset
await hover('h1', { offset: { x: 30, y: 30 }});
// ❌ you need to tell it what element to hover on
await hover({ offset: { x: 30, y: 30 } });
// ❌ hovering outside the viewport - is not useful
await hover('h1', { offset: 15000 });
Full page example:
'use strict';
const expect = require('chai').expect;
const { go, test, hover, text } = require('testim');
test("hover", async () => {
await go('http://jsbin.testim.io/luq/1');
await hover('#moshe');
});
Updated almost 3 years ago