-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogin.pom.ts
More file actions
90 lines (81 loc) · 3.24 KB
/
login.pom.ts
File metadata and controls
90 lines (81 loc) · 3.24 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* eslint-disable */
import { Page, Locator, expect } from '@playwright/test';
import { getValue } from "../utilities/utils";
export class LoginPage {
page: Page;
heading: Locator;
username: Locator;
password: Locator;
submitButton: Locator;
loginDescription: Locator;
loginErrorPopup: Locator;
constructor(page: Page) {
this.page = page;
this.heading = page.getByRole('heading', { name: getValue("message", "login") });
this.username = page.getByPlaceholder(getValue("message","username"));
this.password = page.getByPlaceholder(getValue("message","password"));
this.submitButton = page.getByRole('button', { name: getValue("message", "login") });
this.loginDescription = page.locator('.text-muted');
this.loginErrorPopup = page.locator('.modal-content');
}
async goto() {
await this.page.goto('/');
await this.verifyVisibleLoginPage();
}
async login(username: string, password: string) {
await this.username.fill(username);
await this.password.fill(password);
await this.page.waitForTimeout(1000);
await this.submitButton.click();
await this.page.waitForTimeout(2000);
}
async verifyVisibleLoginPage() {
await expect(this.page).toHaveTitle(/Login/);
await expect(this.heading).toBeVisible();
}
async getLoginDescription() {
return await this.loginDescription.innerText();
}
async verifyLoginErrorPopup() {
await expect(this.loginErrorPopup).toBeVisible();
await expect(this.loginErrorPopup).toContainText(getValue("message", "login_unauthorized"));
}
async closeLoginErrorPopup() {
await this.loginErrorPopup.locator('button').click();
}
}
export class PasswordChangePage {
// http request error
// unauthorized (401)
page: Page;
heading: Locator;
username: Locator;
currentPassword: Locator;
newPassword: Locator;
confirmNewPassword: Locator;
submitButton: Locator;
loginDescription: Locator;
loginErrorPopup: Locator;
constructor(page: Page) {
this.page = page;
this.heading = page.getByRole('heading', { name: getValue("message", "password_force_change") });
this.username = page.locator('#username-input');
this.currentPassword = page.locator('#current-password-input');
this.newPassword = page.locator('#new-password-input');
this.confirmNewPassword = page.locator('#confirm-password-input');
this.submitButton = page.getByRole('button', { name: getValue("message", "password_change") });
this.loginDescription = page.locator('.text-muted');
this.loginErrorPopup = page.locator('.modal-content'); //login_unauthorized
}
async isPasswordChangePageVisible() {
await expect(this.page).toHaveTitle(/Change Password/);
await expect(this.heading).toBeVisible();
}
async doPasswordChangeFlow(username: string, currentPassword: string, newPassword: string) {
await this.username.fill(username);
await this.currentPassword.fill(currentPassword);
await this.newPassword.fill(newPassword);
await this.confirmNewPassword.fill(newPassword);
await this.submitButton.click();
}
}