Button
getButton
​
Check if a button is visible on the page, identified by the text content.
- Utility Function
- Playwright
- Parameters
await getButton(page, <BUTTON TEXT>)
await expect(page.getByRole("button", { name: <BUTTON TEXT>, exact: true })).toBeVisible();
string | number
Make sure the string / number you add is exact (including correct case) otherwise this test will fail.
Use getButtonPartialMatch for a more leniant selector
import { getButton } from "plugandplaywright";
export async function layoutCheck(page) {
await getButton(page, "Text of your button");
}
getButtonPartialMatch
​
Check if a button is visible on the page, identified by the text content.
Your string doesn't have to be exact
- Utility Function
- Playwright
- Parameters
await getButton(page, <BUTTON TEXT>)
await expect(page.getByRole("button", { name: <BUTTON TEXT>})).toBeVisible();
string | number
Your parameter does not have to be a full string, or captialised correctly
import { getButtonPartialMatch } from "plugandplaywright";
export async function layoutCheck(page) {
await getButtonPartialMatch(page, "Text of your button");
}
clickButton
​
Click a button that is visible on the page, identified by the text content.
- Utility Function
- Playwright
- Parameters
await clickButton(page, <BUTTON TEXT>)
await page.getByRole("button", { name: <BUTTON TEXT>, exact: true }).click();
await page.waitForLoadState("load");
string | number
Not only click the button 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 clickButtonPartialMatch for a more leniant selector
import { clickButton } from "plugandplaywright";
export async function layoutCheck(page) {
await clickButton(page, "Text of your button");
}
clickButtonPartialMatch
​
Click a button that is visible on the page, identified by the text content.
- Utility Function
- Playwright
- Parameters
await clickButtonPartialMatch(page, <BUTTON TEXT>)
await page.getByRole("button", { name: <BUTTON TEXT> }).click();
await page.waitForLoadState("load");
string | number
Not only click the button 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 { clickButtonPartialMatch } from "plugandplaywright";
export async function layoutCheck(page) {
await clickButtonPartialMatch(page, "text of yoUr buTt");
}
hoverButton
​
Hover a button that is visible on the page, identified by the text content.
- Utility Function
- Playwright
- Parameters
await hoverButton(page, <BUTTON TEXT>)
await page.getByRole("button", { name: <BUTTON TEXT>, exact: true }).hover();
string | number
Make sure the string / number you add is exact (including correct case) otherwise this test will fail.
Use hoverButtonPartialMatch for a more leniant selector
import { hoverButton } from "plugandplaywright";
export async function layoutCheck(page) {
await hoverButton(page, "Text of your button");
}
hoverButtonPartialMatch
​
Hover a button that is visible on the page, identified by the text content.
- Utility Function
- Playwright
- Parameters
await hoverButtonPartialMatch(page, <BUTTON TEXT>)
await page.getByRole("button", { name: <BUTTON TEXT> }).hover();
string | number
Your parameter does not have to be a full string, or captialised correctly
import { hoverButtonPartialMatch } from "plugandplaywright";
export async function layoutCheck(page) {
await hoverButtonPartialMatch(page, "text of yoUr buTt");
}
scrollToButton
​
Scroll the page til this button is within the viewport.
- Utility Function
- Playwright
- Parameters
await scrollToButton(page, <BUTTON TEXT>)
await page.getByRole("button", { name: <BUTTON TEXT>, exact: true }).scrollIntoViewIfNeeded();
string | number
Make sure the string / number you add is exact (including correct case) otherwise this test will fail.
Use scrollToButtonPartialMatch for a more leniant selector
import { scrollToButton } from "plugandplaywright";
export async function layoutCheck(page) {
await scrollToButton(page, "Text of your button");
}
scrollToButtonPartialMatch
​
Scroll the page til this button is within the viewport.
- Utility Function
- Playwright
- Parameters
await scrollToButtonPartialMatch(page, <BUTTON TEXT>)
await page.getByRole("button", { name: <BUTTON TEXT> }).scrollIntoViewIfNeeded();
string | number
Your parameter does not have to be a full string, or captialised correctly
import { scrollToButtonPartialMatch } from "plugandplaywright";
export async function layoutCheck(page) {
await scrollToButtonPartialMatch(page, "text of yoUr buTt");
}