-
Notifications
You must be signed in to change notification settings - Fork 1
/
Login.test.ts
45 lines (35 loc) · 1.22 KB
/
Login.test.ts
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { test, expect, Page } from "@playwright/test";
let page: Page;
test.beforeEach(async ({ browser }) => {
page = await browser.newPage();
await page.goto("/");
// logout first
const logout = await page.locator("a", { hasText: "Logout" });
await logout.click();
});
test.afterAll(async () => {
await page.close();
});
test.describe("playwright e2e test for login page", () => {
test("success login", async () => {
const email = await page.locator("#email");
const password = await page.locator("#password");
const submitButton = await page.locator("button[type=submit]");
await email.clear();
await email.type("eve.holt@reqres.in");
await password.clear();
await password.type("cityslicka");
await submitButton.click();
await expect(page).toHaveURL(/.*home/);
});
test("fail login", async () => {
const email = await page.locator("#email");
const submitButton = await page.locator("button[type=submit]");
await email.clear();
await email.type("test@123123abcabc");
await submitButton.click();
await page.waitForTimeout(3000);
await expect(page.locator("#erroremail")).toBeVisible();
await expect(page.locator("#errorpassword")).toBeVisible();
});
});