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

[🚀 Feature]: Node.js version with firefox missing full page screenshot option #13301

Closed
mrm-ot opened this issue Dec 13, 2023 · 5 comments
Closed
Labels
C-nodejs help wanted Issues looking for contributions I-enhancement

Comments

@mrm-ot
Copy link

mrm-ot commented Dec 13, 2023

Feature and motivation

I have tried python version with firefox driver, it has a extra method for firefox driver.save_full_page_screenshot(screenshot_path).
Samething is missing for Node.js version.

We can use const image = await body.takeScreenshot(true) to take screenshot of whole page but it not same as save_full_page_screenshot. body.takeScreenshot it will scroll to the bottom when taking screenshot and if you have fixed header, header will be at the end of the page. driver.takeScreenshot does not take screenshot of whole page.

I assume it is a firefox only feature and uses built-in firefox screenshot tool. It works well with floating button and fixed header.

Usage example

await firefoxDriver.saveFullPageScreenshot(screenshot_path);
Copy link

@mrm-ot, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol diemol added help wanted Issues looking for contributions and removed needs-triaging labels Dec 13, 2023
Copy link

This issue is looking for contributors.

Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.

@mrm-ot
Copy link
Author

mrm-ot commented Dec 13, 2023

I have added example code with screenshot at the end

python


import time
import selenium.webdriver


options = selenium.webdriver.FirefoxOptions()
options.add_argument('--headless')


with selenium.webdriver.Firefox(options=options) as driver:
    page_url = 'https://chenzhihao.github.io/sticky-Nav/'
    driver.get(page_url)
    time.sleep(1)
    screenshot_path = 'screenshot.png'
    driver.save_full_page_screenshot(screenshot_path)

Node.js


import fs from 'fs';
import { Builder, By } from 'selenium-webdriver';


const driver = await new Builder().forBrowser("firefox").build();

await driver.get('https://chenzhihao.github.io/sticky-Nav/');

const body = driver.findElement(By.css('body'));

await new Promise(resolve => setTimeout(resolve, 1000));

const image = await body.takeScreenshot(true)
fs.writeFile('screenshot2.png', image, 'base64', console.log);

const image3 = await driver.takeScreenshot()
fs.writeFile('screenshot3.png', image3, 'base64', console.log);

await driver.quit();

Python Screenshot
Node.js Screenshot with body (navbar header is at bottom)
Node.js Screenshot with driver (not full page)

@harsha509
Copy link
Member

Landed changes with commit 111941b !

Closing as resolved.

Copy link

github-actions bot commented May 5, 2024

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-nodejs help wanted Issues looking for contributions I-enhancement
Projects
None yet
Development

No branches or pull requests

4 participants