08ea5fbe98
添加用户管理视图、API和状态管理文件
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
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<string> {
|
|
const activeTab = await this.page.$(this.selectors.activeTab);
|
|
return await activeTab?.textContent() || '';
|
|
}
|
|
|
|
async isTabActive(tabName: 'calendar' | 'almanac' | 'user'): Promise<boolean> {
|
|
const activeTab = await this.getActiveTab();
|
|
const expectedText = tabName === 'calendar' ? '万年历' : tabName === 'almanac' ? '黄历' : '我的';
|
|
return activeTab.includes(expectedText);
|
|
}
|
|
|
|
async getAllTabTexts(): Promise<string[]> {
|
|
const tabs = await this.page.$$(this.selectors.tabText);
|
|
const texts: string[] = [];
|
|
for (const tab of tabs) {
|
|
texts.push(await tab.textContent() || '');
|
|
}
|
|
return texts;
|
|
}
|
|
}
|