Context:
In Page Object Model, I would create a page object like this
import { Locator, Page } from '@playwright/test';
export class PlaywrightDevPage {
readonly page: Page;
readonly getStartedLink: Locator;
constructor(page: Page) {
this.page = page;
this.getStartedLink = page.locator('text=Get started');
}
async goto() {
await this.page.goto('https://playwright.dev');
// duplicate selector appearence
await this.page.waitForSelector(''text=Get started'');
}
}
Because Locator.isVisible() does not wait for the element to become visible and returns immediately, I have to use waitForSelector method. But there is no supported function like page.waitForSelector(locator: Locator) or page.waitForLocator(locator: Locator) or Locator.waitUtil(state: State).
Context:
In Page Object Model, I would create a page object like this
Because Locator.isVisible() does not wait for the element to become visible and returns immediately, I have to use waitForSelector method. But there is no supported function like page.waitForSelector(locator: Locator) or page.waitForLocator(locator: Locator) or Locator.waitUtil(state: State).