UNPKG

@serenity-js/web

Version:

Serenity/JS Screenplay Pattern library offering a flexible, web driver-agnostic approach for interacting with web-based user interfaces and components, suitable for various testing contexts

68 lines 2.27 kB
import type { Answerable, AnswersQuestions, Interaction, UsesAbilities } from '@serenity-js/core'; import type { PageElement } from '../models'; import { PageElementInteraction } from './PageElementInteraction'; /** * Instructs an [actor](https://serenity-js.org/api/core/class/Actor/) who has the [ability](https://serenity-js.org/api/core/class/Ability/) to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/) * to hover the mouse pointer over a given [`PageElement`](https://serenity-js.org/api/web/class/PageElement/). * * ## Example widget * ```html * <a data-test="example-link" * class="off" * onmouseover="this.className='on';" * onmouseout="this.className='off';" * href="/">hover over me</a> * ``` * * ## Lean Page Object describing the widget * * ```ts * import { By, PageElement } from '@serenity-js/web' * * class Example { * static link = () => * PageElement.located(By.css('[data-test="example-link"]')) * .describedAs('example link') * } * ``` * * ## Hovering over an element * * ```ts * import { actorCalled } from '@serenity-js/core' * import { Hover, CssClasses } from '@serenity-js/web' * import { Ensure, equals } from '@serenity-js/assertions' * * await actorCalled('Hank') * .whoCan(BrowseTheWeb.using(browser)) * .attemptsTo( * Ensure.that(CssClasses.of(Example.link()), equals([ 'off' ])), * * Hover.over(Example.link), * Ensure.that(CssClasses.of(Example.link()), equals([ 'on' ])), * ) * ``` * * ## Learn more * * - [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/) * - [`PageElement`](https://serenity-js.org/api/web/class/PageElement/) * * @group Activities */ export declare class Hover extends PageElementInteraction { private readonly element; /** * Instantiates this [`Interaction`](https://serenity-js.org/api/core/class/Interaction/) * * @param pageElement * The element to be hovered over */ static over(pageElement: Answerable<PageElement>): Interaction; protected constructor(element: Answerable<PageElement>); /** * @inheritDoc */ performAs(actor: UsesAbilities & AnswersQuestions): Promise<void>; } //# sourceMappingURL=Hover.d.ts.map