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 { 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 { return await this.searchResults.locator('[data-testid="search-result-card"], .search-result-card').count(); } async isSearchResultsVisible(): Promise { return await this.searchResults.isVisible().catch(() => false); } async isSearchHistoryVisible(): Promise { 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 }); } }