Files
mygit/e2e/helpers/pages/base-page.ts
T
DuckQ1u 93d1b7c3d3
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
first commit
2026-04-22 19:51:20 +07:00

47 lines
1.2 KiB
TypeScript

import {PageHttpLogger} from './page-http-logger';
import {appConfig} from '@/helpers/utils/app-config';
import type {Locator, Page, Response} from '@playwright/test';
export interface pageGotoOptions {
referer?: string;
timeout?: number;
waitUntil?: 'load' | 'domcontentloaded'|'networkidle'|'commit';
}
export class BasePage {
private logger?: PageHttpLogger;
private readonly debugLogs = appConfig.debugLogs;
public pageUrl: string = '';
protected readonly page: Page;
public readonly body: Locator;
constructor(page: Page, pageUrl: string = '') {
this.page = page;
this.pageUrl = pageUrl;
this.body = page.locator('body');
if (this.isDebugEnabled()) {
this.logger = new PageHttpLogger(page);
this.logger.setup();
}
}
async refresh() {
await this.page.reload();
}
async goto(url?: string, options?: pageGotoOptions): Promise<null | Response> {
const urlToVisit = url || this.pageUrl;
return await this.page.goto(urlToVisit, options);
}
async pressKey(key: string) {
await this.page.keyboard.press(key);
}
private isDebugEnabled(): boolean {
return this.debugLogs;
}
}