Skip to content

Restore original window size when taking full size screenshot #1508

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

Merged
merged 3 commits into from
Feb 24, 2019
Merged
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
6 changes: 5 additions & 1 deletion lib/helper/WebDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,8 @@ class WebDriver extends Helper {
}

/* eslint-disable prefer-arrow-callback, comma-dangle, prefer-const */
const originalWindowSize = await this.browser.getWindowSize();

let { width, height } = await this.browser.execute(function () {
return {
height: document.body.scrollHeight,
Expand All @@ -1298,7 +1300,9 @@ class WebDriver extends Helper {

await this.browser.setWindowSize(width, height);
this.debug(`Screenshot has been saved to ${outputFile}, size: ${width}x${height}`);
return this.browser.saveScreenshot(outputFile);
const buffer = await this.browser.saveScreenshot(outputFile);
await this.browser.setWindowSize(originalWindowSize.width, originalWindowSize.height);
return buffer;
}


Expand Down