Closes #27451 --------- Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com> Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
23 lines
558 B
TypeScript
23 lines
558 B
TypeScript
import { expect, test } from '@playwright/test';
|
|
/**
|
|
* Assert a text is present on the visited page.
|
|
* @param page
|
|
* @param path
|
|
* @param title
|
|
* @param selector
|
|
*/
|
|
export function assertTextOnPage(
|
|
path: string,
|
|
title: string,
|
|
selector: string = 'h1'
|
|
): void {
|
|
// eslint-disable-next-line playwright/valid-title
|
|
test.describe(path, () => {
|
|
test(`should display "${title}"`, async ({ page }) => {
|
|
await page.goto(path);
|
|
const locator = page.locator(selector);
|
|
await expect(locator).toContainText(title);
|
|
});
|
|
});
|
|
}
|