-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[rb] Add support for full page screenshots in Chrome and Edge #16725
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
[rb] Add support for full page screenshots in Chrome and Edge #16725
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
|
interesting... has Chrome always supported this? The reason in #14116 that this was Firefox-only was that Chrome didn't provide this endpoint. If this now works, I'm going to add the same thing in the Python bindings. |
|
@jspanjers Edge browser inherits this same functionality and it probably works there also. Can you add the same test for that? |
| width, height = png_size(screenshot) | ||
|
|
||
| expect(width).to be >= viewport_width | ||
| expect(width).to be <= viewport_width |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
|
@jspanjers can you check the failed screenshot tests in CI? |
|
Firstly, thank you for tracking down the implementation details for this and submitting a code fix. The problem with the screenshot endpoint in Chrome (and Edge) is that it is not w3c compliant. It must be namespaced correctly for us to implement it. I requested it be updated by them several years ago and they declined - https://issues.chromium.org/issues/42322971 Also, the log endpoint is no longer supported, so we can't add that back, either. We hope to have a better future-compatible implementation for this soon using the w3c WebDriver BiDi specification. |
User description
🔗 Related Issues
Provides a quickfix for #14116.
💥 What does this PR do?
Implements full page screenshots for Chromium browsers for the Ruby language.
It extends the Chromium driver with full page screenshot functionality, similar to how it was implemented before for the Firefox driver. It uses Chrome's
session/:session_id/screenshot/fullendpoint.🔧 Implementation Notes
Issue #14116 was originally opened to raise the issue that full page screenshots are not working for the ruby bindings in Chrome/Edge using
driver.save_screenshot(path, full_page: true). This is fixed here.💡 Additional Considerations
In Issue #14116 there is discussion about rewriting Selenium's screenshot functionality to use BiDi, and changing the API to something like
driver.page.screenshot(params). I believe rewriting to use BiDi can be done later, as well as changing the API. I am also not sure that there is a specification for taking full page screenshots with BiDi yet.🔄 Types of changes
PR Type
Enhancement
Description
Adds full page screenshot support for Chrome in Ruby bindings
Implements
full_screenshotmethod in Chromium driver bridgeRegisters new
full_page_screenshotendpoint for Chrome driverIncludes integration test validating full page screenshot functionality
Diagram Walkthrough
File Walkthrough
driver.rb
Register FullPageScreenshot extension in Chromium driverrb/lib/selenium/webdriver/chromium/driver.rb
DriverExtensions::FullPageScreenshotto the EXTENSIONS list forChromium driver
features.rb
Implement full page screenshot bridge and endpointrb/lib/selenium/webdriver/chromium/features.rb
full_page_screenshotcommand mapping to Chrome's screenshot/fullendpoint
full_screenshotmethod in Bridge module to execute thecommand
capability
driver_spec.rb
Add full page screenshot integration testrb/spec/integration/selenium/webdriver/chrome/driver_spec.rb
capture
save_screenshotwithfull_page: trueparameter