SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
29.74k stars 8.02k forks source link

[🚀 Feature]: Full page screenshots for Chrome #14116

Open lwassermann opened 3 weeks ago

lwassermann commented 3 weeks ago

Feature and motivation

In the Ruby Selenium Driver, it is possible to provide the full_page-argument to save_screenshot (documented here).

That option only work when using Selenium with Firefox. Not Chrome or Edge.

4 years ago, there was already a discussion to add this feature: https://github.com/SeleniumHQ/selenium/issues/8705 Unfortunately, that got closed as a duplicate of BiDi-work. That work referenced screenshots, but did not actually include that feature. And it is merged for some time now.

From other issues, I'm not quite sure whether that limitation is only in the ruby-bindings, or shared with other languages.

Or maybe I'm holding it wrong? If so, I'd be greatful if you could add the correct way to take screenshots to the method documentation 🙏

Usage example

I'm currently adding visual regression tests, creating screenshots of our website or something like Storybook. So I have some pages that are very long, and others that are less than a normal screen height. Taking long pictures with a lot of white-space of everything seems wasteful.

For now, we'll use Firefox. But since this was already closed as done, but actually isn't, I thought I'd re-raise this 😇

github-actions[bot] commented 3 weeks ago

@lwassermann, 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!

titusfortner commented 2 weeks ago
  1. There is a method for firefox because Mozilla created a specific endpoint for it that was easy to just use.
  2. There is a way to do it currently in Chrome that uses Chrome Devtools Protocol, but we are not adding wrappers to CDP because we are looking to replace it with the BiDi spec.

This is a good request to add to a High Level API for BiDi, though, and we are no longer tracking that in another issue, so I'll leave this open.

@pujagani what do you think is the right API for this? driver.page.screenshot(params)? (does page make sense in this context vs the script context we're using with other methods? Let's discuss.

pujagani commented 2 weeks ago

Since "captureScreenshot" command comes under browsing context in the spec https://w3c.github.io/webdriver-bidi/#command-browsingContext-captureScreenshot. I think page looks good to me. What do others think? @diemol @p0deje

diemol commented 2 weeks ago

page sounds good. But how do we bring together the current screenshot methods and this new one?