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.
218 lines (217 loc) • 7.33 kB
TypeScript
import { DataTable } from "@cucumber/cucumber";
import { CustomWorld } from "../helpers/world";
/**
* Asserts that the current page's full URL exactly matches the expected string.
*
* ```gherkin
* Then I see URL {string}
* ```
*
* @param expectedUrl - The exact URL string expected.
*
* @example
* Then I see URL "https://example.com/dashboard"
*
* @remarks
* This step retrieves the current URL from `this.page.url()` and performs a strict equality check.
* @category URL Assertion Steps
*/
export declare function Then_I_see_URL(this: CustomWorld, expectedUrl: string): Promise<void>;
/**
* Asserts that the current page's full URL does NOT match the given string.
*
* ```gherkin
* Then I do not see URL {string}
* ```
*
* @param notExpectedUrl - The URL string that is NOT expected.
*
* @example
* Then I do not see URL "https://example.com/login"
*
* @remarks
* This step retrieves the current URL from `this.page.url()` and performs a strict inequality check.
* @category URL Assertion Steps
*/
export declare function Then_I_do_not_see_URL(this: CustomWorld, notExpectedUrl: string): Promise<void>;
/**
* Asserts that the current page's full URL contains the expected substring.
*
* ```gherkin
* Then I see URL contains {string}
* ```
*
* @param expectedPart - The substring expected to be present in the URL.
*
* @example
* Then I see URL contains "/dashboard"
*
* @remarks
* This step retrieves the current URL from `this.page.url()` and checks if it includes the `expectedPart`.
* @category URL Assertion Steps
*/
export declare function Then_I_see_URL_contains(this: CustomWorld, expectedPart: string): Promise<void>;
/**
* Asserts that the current page's full URL does NOT contain the given substring.
*
* ```gherkin
* Then I do not see URL contains {string}
* ```
*
* @param notExpectedPart - The substring that is NOT expected to be present in the URL.
*
* @example
* Then I do not see URL contains "/login"
*
* @remarks
* This step retrieves the current URL from `this.page.url()` and asserts that it does not include the `notExpectedPart`.
* @category URL Assertion Steps
*/
export declare function Then_I_do_not_see_URL_contains(this: CustomWorld, notExpectedPart: string): Promise<void>;
/**
* Asserts that the current `window.location.href` (full URL) matches the expected string.
* This is an alias for "Then I see URL {string}".
*
* ```gherkin
* Then I see location {string}
* ```
*
* @param expectedHref - The exact `window.location.href` string expected.
*
* @example
* Then I see location "https://example.com/dashboard"
*
* @remarks
* This step executes `window.location.href` in the browser context and compares it strictly.
* It's functionally identical to {@link Then_I_see_URL | "Then I see URL {string}"}.
* @category Location Assertion Steps
*/
export declare function Then_I_see_location(this: CustomWorld, expectedHref: string): Promise<void>;
/**
* Asserts that the current `window.location.pathname` (path part of URL) matches the expected string.
*
* ```gherkin
* Then I see pathname {string}
* ```
*
* @param expectedPathname - The exact pathname string expected (e.g., "/dashboard").
*
* @example
* Then I see pathname "/dashboard"
*
* @remarks
* This step executes `window.location.pathname` in the browser context and compares it strictly.
* @category Location Assertion Steps
*/
export declare function Then_I_see_pathname(this: CustomWorld, expectedPathname: string): Promise<void>;
/**
* Asserts that the current `window.location.pathname` contains the expected substring.
*
* ```gherkin
* Then I see pathname contains {string}
* ```
*
* @param expectedPart - The substring expected to be present in the pathname.
*
* @example
* Then I see pathname contains "/settings/"
*
* @remarks
* This step executes `window.location.pathname` in the browser context and checks for substring presence.
* @category Location Assertion Steps
*/
export declare function Then_I_see_pathname_contains(this: CustomWorld, expectedPart: string): Promise<void>;
/**
* Asserts that the current `window.location.hash` (fragment identifier) matches the expected string.
*
* ```gherkin
* Then I see hash {string}
* ```
*
* @param expectedHash - The exact hash string expected (e.g., "#section-1").
*
* @example
* Then I see hash "#section"
*
* @remarks
* This step executes `window.location.hash` in the browser context and compares it strictly.
* @category Location Assertion Steps
*/
export declare function Then_I_see_hash(this: CustomWorld, expectedHash: string): Promise<void>;
/**
* Asserts that the current `window.location.hash` contains the expected substring.
*
* ```gherkin
* Then I see hash contains {string}
* ```
*
* @param expectedPart - The substring expected to be present in the hash.
*
* @example
* Then I see hash contains "details"
*
* @remarks
* This step executes `window.location.hash` in the browser context and checks for substring presence.
* @category Location Assertion Steps
*/
export declare function Then_I_see_hash_contains(this: CustomWorld, expectedPart: string): Promise<void>;
/**
* Asserts that the current `window.location.search` (query string) matches the expected string.
*
* ```gherkin
* Then I see search {string}
* ```
*
* @param expectedSearch - The exact search string expected (e.g., "?q=test&page=1").
*
* @example
* Then I see search "?q=test"
*
* @remarks
* This step executes `window.location.search` in the browser context and compares it strictly.
* @category Location Assertion Steps
*/
export declare function Then_I_see_search(this: CustomWorld, expectedSearch: string): Promise<void>;
/**
* Asserts that the current `window.location.search` contains the expected substring.
*
* ```gherkin
* Then I see search contains {string}
* ```
*
* @param expectedPart - The substring expected to be present in the search query.
*
* @example
* Then I see search contains "q=test"
*
* @remarks
* This step executes `window.location.search` in the browser context and checks for substring presence.
* @category Location Assertion Steps
*/
export declare function Then_I_see_search_contains(this: CustomWorld, expectedPart: string): Promise<void>;
/**
* Asserts that multiple parts of the current `window.location` object match expected values from a data table.
*
* ```gherkin
* Then I see location
* | key | value |
* | pathname | /dashboard |
* | hash | #section |
* ```
*
* @param table - A Cucumber DataTable with `key` and `value` columns, where `key` is a `window.location` property (e.g., "pathname", "hash", "origin").
*
* @example
* Then I see location
* | key | value |
* | pathname | /profile |
* | protocol | https: |
* | hostname | myapp.com |
*
* @remarks
* This step retrieves various `window.location` properties as an object and then iterates
* through the data table, asserting that each specified `key` has its corresponding `value`.
* This allows for flexible and combined assertions on the URL components.
* @category Location Assertion Steps
*/
export declare function Then_I_see_location_parts(this: CustomWorld, table: DataTable): Promise<void>;