Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: screenshots for sessions #4747

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
@@ -2287,14 +2287,6 @@ class Playwright extends Helper {
const fullPageOption = fullPage || this.options.fullPageScreenshots
let outputFile = screenshotOutputFolder(fileName)

this.debugSection('Screenshot', relativeDir(outputFile))

await this.page.screenshot({
path: outputFile,
fullPage: fullPageOption,
type: 'png',
})

if (this.activeSessionName) {
for (const sessionName in this.sessionPages) {
const activeSessionPage = this.sessionPages[sessionName]
@@ -2311,6 +2303,14 @@ class Playwright extends Helper {
}
}
}

this.debugSection('Screenshot', relativeDir(outputFile))

await this.page.screenshot({
path: outputFile,
fullPage: fullPageOption,
type: 'png',
})
}

/**
16 changes: 8 additions & 8 deletions lib/helper/Puppeteer.js
Original file line number Diff line number Diff line change
@@ -1954,14 +1954,6 @@ class Puppeteer extends Helper {
const fullPageOption = fullPage || this.options.fullPageScreenshots
let outputFile = screenshotOutputFolder(fileName)

this.debug(`Screenshot is saving to ${outputFile}`)

await this.page.screenshot({
path: outputFile,
fullPage: fullPageOption,
type: 'png',
})

if (this.activeSessionName) {
for (const sessionName in this.sessionPages) {
const activeSessionPage = this.sessionPages[sessionName]
@@ -1978,6 +1970,14 @@ class Puppeteer extends Helper {
}
}
}

this.debug(`Screenshot is saving to ${outputFile}`)

await this.page.screenshot({
path: outputFile,
fullPage: fullPageOption,
type: 'png',
})
}

async _failed(test) {
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -94,8 +94,8 @@
"figures": "3.2.0",
"fn-args": "4.0.0",
"fs-extra": "11.2.0",
"glob": "^11.0.0",
"fuse.js": "^7.0.0",
"glob": "^11.0.0",
"html-minifier-terser": "7.2.0",
"inquirer": "6.5.2",
"invisi-data": "^1.0.0",
5 changes: 2 additions & 3 deletions test/acceptance/session_test.js
Original file line number Diff line number Diff line change
@@ -81,7 +81,6 @@ Scenario('should save screenshot for sessions @Puppeteer @Playwright', async fun
await I.amOnPage('/form/bug1467')
await I.saveScreenshot('original.png')
await I.amOnPage('/')
await I.saveScreenshot('main_session.png')
session('john', async () => {
await I.amOnPage('/form/bug1467')
event.dispatcher.emit(event.test.failed, this)
@@ -94,8 +93,8 @@ Scenario('should save screenshot for sessions @Puppeteer @Playwright', async fun
await I.expectEqual(original, failed)

// Assert that screenshots of sessions are created
const [main_original, session_failed] = await I.getSHA256Digests([`${output_dir}/main_session.png`, `${output_dir}/john_${fileName}.failed.png`])
await I.expectNotEqual(main_original, session_failed)
const [main_original] = await I.getSHA256Digests([`${output_dir}/${fileName}.failed.png`])
await I.expectNotEqual(main_original, failed)
})

Scenario('should throw exception and close correctly @Puppeteer @Playwright', ({ I }) => {