-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
testUtils.js
31 lines (26 loc) · 959 Bytes
/
testUtils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { expect } from "@playwright/test";
export const pauseIfVideoRecording = async (page) => {
let isVideoRecorded = (await page.video()) ? true : false;
if (isVideoRecorded) {
await page.waitForTimeout(500);
}
};
export const setInputAndAssert = async (page, selector, value) => {
await page.fill(selector, value);
const actualValue = await page.inputValue(selector);
expect(actualValue).toBe(value);
};
export const selectAndAssert = async (page, selector, value) => {
await page.selectOption(selector, { value: value });
const selectedValue = await page.$eval(selector, (select) => select.value);
expect(selectedValue).toBe(value);
};
export const waitForSelectorToBeVisible = async (page, selector) => {
await page.waitForSelector(selector, {
state: "visible",
});
};
export const clickWhenSelectorIsVisible = async (page, selector) => {
waitForSelectorToBeVisible(page, selector);
await page.click(selector);
};