Removes the explicit URL declaration from the page classes. The URL validation and navigation are now handled directly within the tests, providing greater flexibility and control over test execution and removing the need to manage URLs within each page object.
34 lines
No EOL
876 B
TypeScript
34 lines
No EOL
876 B
TypeScript
import test, { Locator, Page } from '@playwright/test';
|
|
|
|
import { BasePage } from './BasePage';
|
|
|
|
// This file is an example of a Page Object Model
|
|
|
|
export class LeadgenHomePage extends BasePage {
|
|
|
|
readonly page: Page;
|
|
readonly letsGetStartedButton: Locator;
|
|
readonly zipTextbox: Locator;
|
|
|
|
constructor(page: Page) {
|
|
super(page);
|
|
|
|
this.page = page;
|
|
this.letsGetStartedButton = this.page.locator('#zipCodeTextboxButton');
|
|
this.zipTextbox = this.page.getByPlaceholder('Enter service ZIP code');
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto(process.env['BASE_URL']!);
|
|
}
|
|
|
|
async letsGetStarted(zip: string) {
|
|
await this.zipTextbox.fill(zip);
|
|
await this.letsGetStartedButton.click();
|
|
}
|
|
|
|
async isCurrentVariant(): Promise<boolean> {
|
|
return await this.zipTextbox.isVisible();
|
|
}
|
|
|
|
} |