playwright-js/tests/common.ts
2024-09-30 12:08:58 +08:00

30 lines
643 B
TypeScript

import { Locator, Page } from "@playwright/test";
import { test as base } from "@playwright/test";
type MyFixtures = {
homePage: HomePage;
};
export const test = base.extend<MyFixtures>({
homePage: async ({ page }, use) => {
const homePage = new HomePage(page);
await use(homePage);
},
});
class HomePage {
private page: Page;
private $start: Locator;
constructor(page: Page) {
this.page = page;
this.$start = this.page.getByRole("link", { name: "Get started" });
}
async clickStart() {
await this.$start.click();
}
}
export { expect } from "@playwright/test";