-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloginPage.po.ts
More file actions
57 lines (45 loc) · 1.4 KB
/
Copy pathloginPage.po.ts
File metadata and controls
57 lines (45 loc) · 1.4 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
import type { Locator, Page } from "@playwright/test";
import type { TUserCreds } from "../../types/User.types";
import BasePage from "../basePage.po";
export class LoginPage extends BasePage {
constructor(page: Page) {
super(page, "/login");
}
get signUpHeader(): Locator {
return this.page.getByRole("heading", { name: "New User Signup!" });
}
get loginHeader(): Locator {
return this.page.getByRole("heading", { name: "Login to your account" });
}
get nameInput(): Locator {
return this.page.getByTestId("signup-name");
}
get emailSignUpInput(): Locator {
return this.page.getByTestId("signup-email");
}
get emailLoginInput(): Locator {
return this.page.getByTestId("login-email");
}
get passwordInput(): Locator {
return this.page.getByTestId("login-password");
}
get loginBtn(): Locator {
return this.page.getByTestId("login-button");
}
get signUpBtn(): Locator {
return this.page.getByTestId("signup-button");
}
errorMessage(text: string): Locator {
return this.page.locator("p").filter({ hasText: text });
}
async loginAs(creds: TUserCreds): Promise<void> {
await this.emailLoginInput.fill(creds.email);
await this.passwordInput.fill(creds.password);
await this.loginBtn.click();
}
async beginSignUp(name: string, email: string): Promise<void> {
await this.nameInput.fill(name);
await this.emailSignUpInput.fill(email);
await this.signUpBtn.click();
}
}