jan/electron/tests/pages/commonActions.ts
Van Pham 82b361a5be
feat: Initialize POM structure with fixtures on Playwright (#2015)
* feat: video recorder on failures

* feat: fixture for sample page class

* feat: video recorder on failures

* feat: fixture for sample page class

* feat: video recorder on failures

* feat: fixture for sample page class

* feat: Apply Screenshot on failures

* feat: set timeout by default

* chore: clean up import

* feat: video recorder on failures

* feat: fixture for sample page class

* feat: add wait for app update

* chore: correct timeout

* chore: correct timeout

* chore: test timeout

* chore: test timeout

* chore: test timeout

* chore: browser context config

* chore: temporally disable the video recorder to bypass issue
2024-02-15 20:18:02 +07:00

35 lines
854 B
TypeScript

import { Page, TestInfo } from '@playwright/test'
import { page } from '../config/fixtures'
export class CommonActions {
private testData = new Map<string, string>()
constructor(
public page: Page,
public testInfo: TestInfo
) {}
async takeScreenshot(name: string) {
const screenshot = await page.screenshot({
fullPage: true,
})
const attachmentName = `${this.testInfo.title}_${name || new Date().toISOString().slice(5, 19).replace(/[-:]/g, '').replace('T', '_')}`
await this.testInfo.attach(attachmentName.replace(/\s+/g, ''), {
body: screenshot,
contentType: 'image/png',
})
}
async hooks() {
console.log('hook from the scenario page')
}
setValue(key: string, value: string) {
this.testData.set(key, value)
}
getValue(key: string) {
return this.testData.get(key)
}
}