Skip to content

Commit 435ce10

Browse files
committed
fix: screenshots for sessions
1 parent 117c6c1 commit 435ce10

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

lib/helper/Playwright.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,14 +2287,6 @@ class Playwright extends Helper {
22872287
const fullPageOption = fullPage || this.options.fullPageScreenshots
22882288
let outputFile = screenshotOutputFolder(fileName)
22892289

2290-
this.debugSection('Screenshot', relativeDir(outputFile))
2291-
2292-
await this.page.screenshot({
2293-
path: outputFile,
2294-
fullPage: fullPageOption,
2295-
type: 'png',
2296-
})
2297-
22982290
if (this.activeSessionName) {
22992291
for (const sessionName in this.sessionPages) {
23002292
const activeSessionPage = this.sessionPages[sessionName]
@@ -2311,6 +2303,14 @@ class Playwright extends Helper {
23112303
}
23122304
}
23132305
}
2306+
2307+
this.debugSection('Screenshot', relativeDir(outputFile))
2308+
2309+
await this.page.screenshot({
2310+
path: outputFile,
2311+
fullPage: fullPageOption,
2312+
type: 'png',
2313+
})
23142314
}
23152315

23162316
/**

lib/helper/Puppeteer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,14 +1954,6 @@ class Puppeteer extends Helper {
19541954
const fullPageOption = fullPage || this.options.fullPageScreenshots
19551955
let outputFile = screenshotOutputFolder(fileName)
19561956

1957-
this.debug(`Screenshot is saving to ${outputFile}`)
1958-
1959-
await this.page.screenshot({
1960-
path: outputFile,
1961-
fullPage: fullPageOption,
1962-
type: 'png',
1963-
})
1964-
19651957
if (this.activeSessionName) {
19661958
for (const sessionName in this.sessionPages) {
19671959
const activeSessionPage = this.sessionPages[sessionName]
@@ -1978,6 +1970,14 @@ class Puppeteer extends Helper {
19781970
}
19791971
}
19801972
}
1973+
1974+
this.debug(`Screenshot is saving to ${outputFile}`)
1975+
1976+
await this.page.screenshot({
1977+
path: outputFile,
1978+
fullPage: fullPageOption,
1979+
type: 'png',
1980+
})
19811981
}
19821982

19831983
async _failed(test) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
"figures": "3.2.0",
9595
"fn-args": "4.0.0",
9696
"fs-extra": "11.2.0",
97-
"glob": "^11.0.0",
9897
"fuse.js": "^7.0.0",
98+
"glob": "^11.0.0",
9999
"html-minifier-terser": "7.2.0",
100100
"inquirer": "6.5.2",
101101
"invisi-data": "^1.0.0",

test/acceptance/session_test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ Scenario('should save screenshot for sessions @Puppeteer @Playwright', async fun
8181
await I.amOnPage('/form/bug1467')
8282
await I.saveScreenshot('original.png')
8383
await I.amOnPage('/')
84-
await I.saveScreenshot('main_session.png')
8584
session('john', async () => {
8685
await I.amOnPage('/form/bug1467')
8786
event.dispatcher.emit(event.test.failed, this)
@@ -94,8 +93,8 @@ Scenario('should save screenshot for sessions @Puppeteer @Playwright', async fun
9493
await I.expectEqual(original, failed)
9594

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

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

0 commit comments

Comments
 (0)