Skip to content

Commit bd86d5a

Browse files
committed
Set page height better maybe
1 parent 8609304 commit bd86d5a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/playwright/visual.spec.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,18 @@ test('visual', async ({page, extensionId}) => {
5050

5151
// Scroll to the bottom of the page
5252
// document.querySelector('.footer-padding').scrollIntoView()
53-
await page.locator('.footer-padding').evaluate((/** @type {HTMLElement} */ element) => element.scrollIntoView());
53+
await page.locator('.footer-padding').evaluate((/** @type {HTMLElement} */ element) => element.scrollIntoView());
5454

55-
// TODO: remove below
56-
// eslint-disable-next-line no-undef
57-
const pageHeight = await page.evaluate(() => document.body.scrollHeight);
58-
console.log('Page height: ' + pageHeight);
55+
// Get page height by getting the footer and adding height and y position
56+
57+
const footer = /** @type {import('@playwright/test').ElementHandle<HTMLElement>} */ (await page.locator('.footer…-padding').elementHandle());
58+
expect(footer).not.toBe(null);
59+
const boundingBox = /** @type {NonNullable<Awaited<ReturnType<import('@playwright/test').ElementHandle<HTMLElement>['boundingBox']>>>} */ (await footer.boundingBox());
60+
expect(boundingBox).not.toBe(null);
61+
const pageHeight = Math.ceil(boundingBox.y + boundingBox.height);
62+
console.log('Page height:', pageHeight);
63+
64+
await page.setViewportSize({width: 1280, height: pageHeight});
5965

6066
// Wait for any animations or changes to complete
6167
await page.waitForTimeout(500);

0 commit comments

Comments
 (0)