UNPKG

playwright-cucumber-ts-steps

Version:

A collection of reusable Playwright step definitions for Cucumber in TypeScript, designed to streamline end-to-end testing across web, API, and mobile applications.

83 lines (82 loc) 3.21 kB
import { CustomWorld } from "../helpers/world"; /** * Scrolls the previously selected element into the viewport if it's not already visible. * * ```gherkin * When I scroll into view * ``` * * @example * When I find element by selector ".my-long-content-element" * And I scroll into view * * @remarks * This step requires a preceding step that sets the {@link CustomWorld.element | current element} * (e.g., "When I find element by selector"). It uses Playwright's `locator.scrollIntoViewIfNeeded()`, * which scrolls the least amount necessary to make the element visible. * @category Scrolling Steps */ export declare function When_I_scroll_into_view(this: CustomWorld): Promise<void>; /** * Scrolls the main browser window to the given X (horizontal) and Y (vertical) pixel coordinates. * * ```gherkin * When I scroll to position {int} {int} * ``` * * @param x - The X-coordinate in pixels to scroll to. * @param y - The Y-coordinate in pixels to scroll to. * * @example * When I scroll to position 0 500 * * @remarks * This step directly executes `window.scrollTo(x, y)` in the browser's context. * It sets the absolute scroll position of the main document. * This is similar to `When I scroll window to position {int} {int}` and `When I scroll window to x {int} and y {int}`. * Consider consolidating if their functionality is identical. * @category Scrolling Steps */ export declare function When_I_scroll_to_position(this: CustomWorld, x: number, y: number): Promise<void>; /** * Scrolls the main browser window to the given X (horizontal) and Y (vertical) pixel coordinates. * This step is an alias for "When I scroll to position {int} {int}". * * ```gherkin * When I scroll window to position {int} {int} * ``` * * @param x - The X-coordinate in pixels to scroll to. * @param y - The Y-coordinate in pixels to scroll to. * * @example * When I scroll window to position 0 500 * * @remarks * This step is functionally identical to {@link When_I_scroll_to_position | "When I scroll to position {int} {int}"}. * It executes `window.scrollTo(x, y)` in the browser's context. * @category Scrolling Steps */ export declare function When_I_scroll_window_to_position(this: CustomWorld, x: number, y: number): Promise<void>; /** * Scrolls the main browser window to the given X (horizontal) and Y (vertical) pixel coordinates. * This step is another alias for "When I scroll to position {int} {int}". * * ```gherkin * When I scroll window to x {int} and y {int} * ``` * * @param x - The X-coordinate in pixels to scroll to. * @param y - The Y-coordinate in pixels to scroll to. * * @example * When I scroll window to x 0 and y 500 * * @remarks * This step is functionally identical to {@link When_I_scroll_to_position | "When I scroll to position {int} {int}"} * and {@link When_I_scroll_window_to_position | "When I scroll window to position {int} {int}"}. * It executes `window.scrollTo(x, y)` in the browser's context. * It's recommended to choose one consistent step pattern for window scrolling. * @category Scrolling Steps */ export declare function When_I_scroll_window_to_x_and_y(this: CustomWorld, x: number, y: number): Promise<void>;