import { Page } from '@playwright/test'; export class BottomNavigation { private readonly selectors = { bottomNavigation: '.bottom-navigation', tabButton: '.tab-button', tabText: '.tab-text', activeTab: '.tab-button.active', }; constructor(private page: Page) { } async clickTab(tabName: 'calendar' | 'almanac' | 'user') { const tabs = await this.page.$$(this.selectors.tabButton); for (const tab of tabs) { const text = await tab.textContent(); if (text?.includes(tabName === 'calendar' ? '万年历' : tabName === 'almanac' ? '黄历' : '我的')) { await tab.click(); break; } } } async getActiveTab(): Promise { const activeTab = await this.page.$(this.selectors.activeTab); return await activeTab?.textContent() || ''; } async isTabActive(tabName: 'calendar' | 'almanac' | 'user'): Promise { const activeTab = await this.getActiveTab(); const expectedText = tabName === 'calendar' ? '万年历' : tabName === 'almanac' ? '黄历' : '我的'; return activeTab.includes(expectedText); } async getAllTabTexts(): Promise { const tabs = await this.page.$$(this.selectors.tabText); const texts: string[] = []; for (const tab of tabs) { texts.push(await tab.textContent() || ''); } return texts; } }