WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 8a99a82

Browse files
authored
Merge pull request #14 from auto-qa-hub/tests_for_locked_out_user
test-for-locked-out-user
2 parents b719cf9 + c4a8f12 commit 8a99a82

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

tests/lockedUser.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { test, expect } from "@playwright/test";
2+
import { MainPage } from "./pages/MainPage";
3+
import usersData from "../fixtures/usersData.json";
4+
5+
test.describe("Tests for locked user", () => {
6+
test("Attempt to login with locked user creds", async ({ page }) => {
7+
const mainPage = new MainPage(page);
8+
const username = usersData.users[1];
9+
const password = usersData.password;
10+
11+
await mainPage.visitMainPage();
12+
await mainPage.fillUsername(username);
13+
await mainPage.fillPassword(password);
14+
15+
await expect(page.locator('input[name="user-name"]')).toHaveValue(username);
16+
await expect(page.locator('input[name="password"]')).toHaveValue(password);
17+
18+
await mainPage.loginButton();
19+
await page.getByPlaceholder("Username").isVisible();
20+
await expect(page.locator("svg.error_icon").first()).toBeVisible();
21+
await page.getByPlaceholder("Password").isVisible();
22+
await expect(page.locator("svg.error_icon").last()).toBeVisible();
23+
await expect(
24+
page.locator('div[class*="error-message-container"]')
25+
).toBeVisible();
26+
await page
27+
.getByAltText("Epic sadface: Sorry, this user has been locked out.")
28+
.isVisible();
29+
});
30+
});

tests/pages/MainPage.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Page } from '@playwright/test';
1+
import { Page } from "@playwright/test";
22

33
export class MainPage {
44
constructor(private page: Page) {}
55

66
async visitMainPage() {
7-
await this.page.goto('/');
7+
await this.page.goto("/");
88
}
99
async fillUsername(username: string) {
1010
await this.page.fill('input[name="user-name"]', username);
@@ -13,6 +13,12 @@ export class MainPage {
1313
await this.page.fill('input[name="password"]', password);
1414
}
1515
async loginButton() {
16-
await this.page.click('#login-button');
16+
await this.page.click("#login-button");
17+
}
18+
async loginErrorMessage() {
19+
this.page.locator('div[class*="error-message-container"]');
20+
}
21+
async closeSvgIconForFields() {
22+
this.page.locator("svg.error_icon");
1723
}
1824
}

0 commit comments

Comments
 (0)