pixiu/pages/loginPage.ts
2025-05-29 20:51:45 +08:00

35 lines
1.3 KiB
TypeScript

import { expect, type Locator, type Page } from "@playwright/test";
export class LoginPage {
readonly page: Page;
readonly login_account: Locator;
readonly login_password: Locator;
readonly login_button: Locator;
readonly login_protocol: Locator;
readonly account_pass_hint: Locator;
readonly account_error_hint: Locator;
readonly first_menu: Locator;
constructor(page: Page) {
this.page = page;
this.login_account = page.getByRole('textbox', { name: '请输入您的手机号码' });
this.login_password = page.getByRole('textbox', { name: '请输入登录密码' });
this.login_button = page.getByRole('button', { name: /登\s录/ });
this.login_protocol = page.locator('#agreement');
this.account_pass_hint = page.locator('.pass_svg');
this.account_error_hint = page.locator('.error_svg');
this.first_menu = page.getByText('概况');
}
async user_login(account: string, password: string) {
await this.login_account.fill(account);
await this.account_pass_hint.waitFor();
await this.login_password.fill(password);
await this.login_protocol.click();
await this.login_button.click();
}
user_login_success() {
return this.first_menu;
}
}