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

66 lines 2.04 kB
import type { Answerable, AnswersQuestions, UsesAbilities } from '@serenity-js/core'; import { Interaction } from '@serenity-js/core'; import type { PageElement } from '../models'; /** * 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 scroll until a given [`PageElement`](https://serenity-js.org/api/web/class/PageElement/) comes into view. * * ## Example widget * * ```html * <!-- * an element somewhere at the bottom of the page, * outside of the visible area * --> * <input type="submit" id="submit" /> * ``` * * ## Lean Page Object describing the widget * * ```ts * import { By, PageElement } from '@serenity-js/web' * * class Form { * static submitButton = () => { * PageElement.located(By.id('submit')) * .describedAs('submit button') * } * ``` * * ## Scrolling to element * * ```ts * import { actorCalled } from '@serenity-js/core' * import { Ensure } from '@serenity-js/assertions' * import { Scroll, isVisible } from '@serenity-js/web' * * await actorCalled('Sara') * .attemptsTo( * Scroll.to(Form.submitButton()), * Ensure.that(Form.submitButton(), isVisible()), * ) * ``` * * ## 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 Scroll extends Interaction { private readonly element; /** * Instantiates this [`Interaction`](https://serenity-js.org/api/core/class/Interaction/). * * @param pageElement * The element to scroll to */ static to(pageElement: Answerable<PageElement>): Scroll; protected constructor(element: Answerable<PageElement>); /** * @inheritDoc */ performAs(actor: UsesAbilities & AnswersQuestions): Promise<void>; } //# sourceMappingURL=Scroll.d.ts.map