08ea5fbe98
添加用户管理视图、API和状态管理文件
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { Page, Locator } from '@playwright/test';
|
|
|
|
export class SearchPage {
|
|
readonly page: Page;
|
|
readonly searchInput: Locator;
|
|
readonly searchButton: Locator;
|
|
readonly searchResults: Locator;
|
|
readonly searchHistory: Locator;
|
|
readonly navigationBar: Locator;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
this.searchInput = page.locator('[data-testid="search-input"], .search-input, input[type="search"]');
|
|
this.searchButton = page.locator('[data-testid="search-button"], .search-button, button[type="submit"]');
|
|
this.searchResults = page.locator('[data-testid="search-results"], .search-results');
|
|
this.searchHistory = page.locator('[data-testid="search-history"], .search-history');
|
|
this.navigationBar = page.locator('.uni-tabbar, [class*="tabbar"]');
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto('/#/pages/almanac-search/index');
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async isSearchInputVisible(): Promise<boolean> {
|
|
return await this.searchInput.isVisible().catch(() => false);
|
|
}
|
|
|
|
async fillSearchInput(text: string) {
|
|
await this.searchInput.fill(text);
|
|
}
|
|
|
|
async clickSearchButton() {
|
|
await this.searchButton.click();
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async getSearchResultsCount(): Promise<number> {
|
|
return await this.searchResults.locator('[data-testid="search-result-card"], .search-result-card').count();
|
|
}
|
|
|
|
async isSearchResultsVisible(): Promise<boolean> {
|
|
return await this.searchResults.isVisible().catch(() => false);
|
|
}
|
|
|
|
async isSearchHistoryVisible(): Promise<boolean> {
|
|
return await this.searchHistory.isVisible().catch(() => false);
|
|
}
|
|
|
|
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 });
|
|
}
|
|
}
|