Playwright + Native Node Test Runner (#3893)

This commit is contained in:
Louis Lam
2023-12-17 19:02:22 +08:00
committed by GitHub
parent f24c3583fb
commit 996ff28ed9
23 changed files with 1611 additions and 5073 deletions

27
test/e2e/util-test.js Normal file
View File

@@ -0,0 +1,27 @@
/**
* @param {TestInfo} testInfo Test info
* @param {Page} page Page
* @returns {Promise<void>}
*/
export async function screenshot(testInfo, page) {
const screenshot = await page.screenshot();
await testInfo.attach("screenshot", {
body: screenshot,
contentType: "image/png"
});
}
/**
* @param {Page} page Page
* @returns {Promise<void>}
*/
export async function login(page) {
// Login
await page.getByPlaceholder("Username").click();
await page.getByPlaceholder("Username").fill("admin");
await page.getByPlaceholder("Username").press("Tab");
await page.getByPlaceholder("Password").fill("admin123");
await page.getByLabel("Remember me").check();
await page.getByRole("button", { name: "Login" }).click();
await page.isVisible("text=Add New Monitor");
}