Text
getText
Check if a text content is visible on the page, identified by the string.
- Utility Function
- Playwright
- Parameters
await getText(page, <TEXT CONTENT>)
await expect(page.getByText(<TEXT CONTENT>, { exact: true })).toBeVisible();
string | number
Make sure the string / number you add is exact (including correct case) otherwise this test will fail.
Use getTextPartialMatch for a more leniant selector
import { getText } from "foreplaywright";
export async function layoutCheck(page) {
await getText(page, "Text content to check");
}
getTextPartialMatch
Check if text content is visible on the page, identified by the text content itself.
Your string doesn't have to be exact
- Utility Function
- Playwright
- Parameters
await getText(page, <TEXT CONTENT>)
await expect(page.getByText(<TEXT CONTENT>)).toBeVisible()
string | number
Your parameter does not have to be a full string, or captialised correctly
import { getTextPartialMatch } from "foreplaywright";
export async function layoutCheck(page) {
await getTextPartialMatch(page, "Text content tO Ch");
}
clickText
Click a piece of text that is visible on the page, identified by the text content.
- Utility Function
- Playwright
- Parameters
await clickText(page, <TEXT CONTENT>)
await page.getByText(<TEXT CONTENT>, { exact: true }).click();
await page.waitForLoadState("load");
string | number
Not only click the text but auto wait for the load to complete.
This means the test will wait until the page is ready for the next action.
Make sure the string / number you add is exact (including correct case) otherwise this test will fail.
Use clickTextPartialMatch for a more leniant selector
import { clickText } from "foreplaywright";
export async function layoutCheck(page) {
await clickText(page, "Text Content to CLick");
}
clickTextPartialMatch
Click a piece of text that is visible on the page, identified by the text content.
- Utility Function
- Playwright
- Parameters
await clickTextPartialMatch(page, <TEXT CONTENT>)
await page.getByText(<TEXT CONTENT>).click();
await page.waitForLoadState("load");
string | number
Not only click the text but auto wait for the load to complete.
This means the test will wait until the page is ready for the next action.
Your parameter does not have to be a full string, or captialised correctly
import { clickTextPartialMatch } from "foreplaywright";
export async function layoutCheck(page) {
await clickTextPartialMatch(page, "text conten");
}
hoverText
Hover on a piece of text that is visible on the page, identified by the text content.
- Utility Function
- Playwright
- Parameters
await hoverText(page, <TEXT CONTENT>)
await page.getByText(<TEXT CONTENT>, { exact: true }).hover();
string | number
Make sure the string / number you add is exact (including correct case) otherwise this test will fail.
Use hoverTextPartialMatch for a more leniant selector
import { hoverText } from "foreplaywright";
export async function layoutCheck(page) {
await hoverText(page, "Text Content to Hover");
}
hoverTextPartialMatch
Hover on a piece of text that is visible on the page, identified by the text content.
- Utility Function
- Playwright
- Parameters
await hoverTextPartialMatch(page, <TEXT CONTENT>)
await page.getByText(<TEXT CONTENT>).hover();
string | number
Your parameter does not have to be a full string, or captialised correctly
import { hoverTextPartialMatch } from "foreplaywright";
export async function layoutCheck(page) {
await hoverTextPartialMatch(page, "text conten");
}
scrollToText
Scroll the page til this text is within the viewport.
- Utility Function
- Playwright
- Parameters
await scrollToText(page, <TEXT CONTENT>)
await page.getByText(<TEXT CONTENT>, {exact: true}).scrollIntoViewIfNeeded();
string | number
Make sure the string / number you add is exact (including correct case) otherwise this test will fail.
Use scrollToTextPartialMatch for a more leniant selector
import { scrollToText } from "foreplaywright";
export async function layoutCheck(page) {
await scrollToText(page, "Text Content to Scroll To");
}
scrollToTextPartialMatch
Scroll the page til this text is within the viewport.
- Utility Function
- Playwright
- Parameters
await scrollToTextPartialMatch(page, <TEXT CONTENT>)
await page.getByText(<TEXT CONTENT>).scrollIntoViewIfNeeded();
string | number
Your parameter does not have to be a full string, or captialised correctly
import { scrollToTextPartialMatch } from "foreplaywright";
export async function layoutCheck(page) {
await scrollToTextPartialMatch(page, "t to Scroll To");
}