@testivai/witness-playwright 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/snapshot.js +10 -0
- package/package.json +1 -1
- package/src/snapshot.ts +11 -0
package/dist/snapshot.js
CHANGED
|
@@ -79,6 +79,16 @@ async function snapshot(page, testInfo, name, config) {
|
|
|
79
79
|
const baseFilename = `${timestamp}_${safeName}`;
|
|
80
80
|
// 1. Capture full-page screenshot
|
|
81
81
|
const screenshotPath = path.join(outputDir, `${baseFilename}.png`);
|
|
82
|
+
// Ensure lazy-loaded content is loaded by scrolling to bottom and back
|
|
83
|
+
try {
|
|
84
|
+
await page.evaluate('window.scrollTo(0, Math.max(document.body.scrollHeight, document.documentElement.scrollHeight))');
|
|
85
|
+
await page.waitForTimeout(100);
|
|
86
|
+
await page.evaluate('window.scrollTo(0, 0)');
|
|
87
|
+
await page.waitForTimeout(100);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
// Ignore scroll errors
|
|
91
|
+
}
|
|
82
92
|
await page.screenshot({ path: screenshotPath, fullPage: true });
|
|
83
93
|
// 2. Dump full-page DOM
|
|
84
94
|
const domPath = path.join(outputDir, `${baseFilename}.html`);
|
package/package.json
CHANGED
package/src/snapshot.ts
CHANGED
|
@@ -55,6 +55,17 @@ export async function snapshot(
|
|
|
55
55
|
|
|
56
56
|
// 1. Capture full-page screenshot
|
|
57
57
|
const screenshotPath = path.join(outputDir, `${baseFilename}.png`);
|
|
58
|
+
|
|
59
|
+
// Ensure lazy-loaded content is loaded by scrolling to bottom and back
|
|
60
|
+
try {
|
|
61
|
+
await page.evaluate('window.scrollTo(0, Math.max(document.body.scrollHeight, document.documentElement.scrollHeight))');
|
|
62
|
+
await page.waitForTimeout(100);
|
|
63
|
+
await page.evaluate('window.scrollTo(0, 0)');
|
|
64
|
+
await page.waitForTimeout(100);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
// Ignore scroll errors
|
|
67
|
+
}
|
|
68
|
+
|
|
58
69
|
await page.screenshot({ path: screenshotPath, fullPage: true });
|
|
59
70
|
|
|
60
71
|
// 2. Dump full-page DOM
|