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 bcdda3a

Browse files
test-for-logout-po
1 parent 8a99a82 commit bcdda3a

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed

page_objects_ts/InventoryPage.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { test, expect, Locator, Page } from "@playwright/test";
2+
export class InventoryPage {
3+
page: Page;
4+
userMenu: Locator;
5+
logoutLink: Locator;
6+
7+
constructor(page: Page) {
8+
this.page = page;
9+
this.userMenu = page.locator("#react-burger-menu-btn");
10+
this.logoutLink = page.locator("#logout_sidebar_link");
11+
}
12+
13+
async UserMenuIcon() {
14+
await this.userMenu.click();
15+
}
16+
async Logout() {
17+
await this.logoutLink.click();
18+
}
19+
}
20+
21+
module.exports = { InventoryPage };

tests/Logout.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { test, expect } from "@playwright/test";
2+
import { MainPage } from "../page_objects_ts/MainPage";
3+
import usersData from "../fixtures/usersData.json";
4+
import { InventoryPage } from "../page_objects_ts/InventoryPage";
5+
6+
test.describe("Logout test", () => {
7+
test("Logout flow", async ({ page }) => {
8+
const mainPage = new MainPage(page);
9+
const inventoryPage = new InventoryPage(page);
10+
const username = usersData.users[0];
11+
const password = usersData.password;
12+
13+
await mainPage.visitMainPage();
14+
await mainPage.fillUsername(username);
15+
await mainPage.fillPassword(password);
16+
await mainPage.loginButton();
17+
await page.waitForURL("/inventory.html");
18+
19+
await inventoryPage.UserMenuIcon();
20+
await expect(page.locator("nav[class='bm-item-list']")).toBeVisible();
21+
await inventoryPage.Logout();
22+
await expect(page).toHaveURL('/')
23+
});
24+
});

tests/lockedUser.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect } from "@playwright/test";
2-
import { MainPage } from "./pages/MainPage";
2+
import { MainPage } from "../page_objects_ts/MainPage";
33
import usersData from "../fixtures/usersData.json";
44

55
test.describe("Tests for locked user", () => {

tests/mainPage.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect } from '@playwright/test';
2-
import { MainPage } from './pages/MainPage';
2+
import { MainPage } from '../page_objects_ts/MainPage';
33

44
test.describe("Main Page tests", () => {
55
test('Visit Main Page', async ({ page }) => {

tests/standardUser.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect } from '@playwright/test';
2-
import { MainPage } from './pages/MainPage';
2+
import { MainPage } from '../page_objects_ts/MainPage';
33
import usersData from '../fixtures/usersData.json';
44

55
test.describe("Standard user tests", () => {

0 commit comments

Comments
 (0)