import { Page, Locator } from '@playwright/test'; export class UserPage { readonly page: Page; readonly userInfoCard: Locator; readonly loginButton: Locator; readonly logoutButton: Locator; readonly navigationBar: Locator; constructor(page: Page) { this.page = page; this.userInfoCard = page.locator('[data-testid="user-info-card"], .user-info-card'); this.loginButton = page.locator('[data-testid="login-button"], .login-button'); this.logoutButton = page.locator('[data-testid="logout-button"], .logout-button'); this.navigationBar = page.locator('.uni-tabbar, [class*="tabbar"]'); } async goto() { await this.page.goto('/#/pages/user/index'); await this.page.waitForLoadState('networkidle'); } async isUserInfoVisible(): Promise { return await this.userInfoCard.isVisible().catch(() => false); } async isLoginButtonVisible(): Promise { return await this.loginButton.isVisible().catch(() => false); } async isLogoutButtonVisible(): Promise { return await this.logoutButton.isVisible().catch(() => false); } async clickLogin() { await this.loginButton.click(); } async clickLogout() { await this.logoutButton.click(); } async navigateToTab(tabName: string) { await this.navigationBar.locator(`text=${tabName}`).click(); await this.page.waitForLoadState('networkidle'); } async takeScreenshot(path: string) { await this.page.screenshot({ path, fullPage: true }); } }