import { Locator, Page } from '@playwright/test'; export class PopupContent { private readonly page: Page; private readonly popupLocator: Locator; private readonly confirmButtonLocator: Locator; private readonly cancelButtonLocator: Locator; async confirm(): Promise { await this.confirmButtonLocator.click(); } async cancel(): Promise { await this.cancelButtonLocator.click(); } constructor(page: Page) { this.page = page; this.popupLocator = this.page.locator('div.popup_content'); this.confirmButtonLocator = this.popupLocator.getByRole('button', { name: /确\s认/ }); this.cancelButtonLocator = this.popupLocator.getByRole('button', { name: /取\s消/ }); } }