Scalable Architecture (TS)
Using classes in TS provides the best structure for Page Objects.
Page Class
typescript
import { Page, Locator } from '@playwright/test';
export class DashboardPage {
readonly logoutLink: Locator;
constructor(private page: Page) {
this.logoutLink = page.locator('text=Logout');
}
async logout() {
await this.logoutLink.click();
}
}