-
Notifications
You must be signed in to change notification settings - Fork 169
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
Screenshot not getting entire page #284
Comments
A solution would be to get the document height/width on the fly with some JS : height = Math.max($(document).height(), $(window).height())
width = Math.max($(document).width(), $(window).width()) see: https://stackoverflow.com/a/14744331 and do the screenshot with these values instead of using the configured I've done the test on my side : Here my Capybara config : def register_driver(driver_name)
opts = {
js_errors: true,
timeout: 15,
window_size: [1920, 1200],
browser_options: {
'no-sandbox': nil,
'disable-gpu': nil,
'disable-dev-shm-usage': nil,
'disable-infobars': nil,
'disable-extensions': nil,``
'disable-popup-blocking': nil,
}
}
Capybara.register_driver(driver_name) do |app|
Capybara::Cuprite::Driver.new(app, opts)
end
Capybara::Screenshot.register_driver(driver_name) do |driver, path|
driver.save_screenshot(path)
end
end
# Register our own custom drivers
register_driver(:headless_chrome)
# Configure Capybara JS driver
Capybara.current_driver = :headless_chrome
Capybara.javascript_driver = :headless_chrome
I've made a full page screenshot with the Firefox tool (right click / make a screenshot) and it generates a Running the JS above in a console returns (of course) the right values : Math.max($(document).width(), $(window).width())
2548
Math.max($(document).height(), $(window).height())
2465 |
After studying the various API this does the trick for Cuprite (tested in CI) : Capybara::Screenshot.register_driver(driver_name) do |driver, path|
driver.save_screenshot(path, full: true)
end See: https://github.com/rubycdp/ferrum/blob/master/lib/ferrum/page/screenshot.rb#L31 |
Ferrum doc : https://github.com/rubycdp/ferrum#screenshots |
… to looking up by class (page.driver.class.to_sym) This allows it to still find the driver even if they registered it with Capybara.register_driver using an alias name that isn't known to Capybara::Screenshot. See mattheworiordan#284.
It looks like it already passes So it looks like you only ran into this because you weren't using the default name for the driver (you're calling yours (I've run into similar problems when I've tried to use names that make more sense to me, like calling my Firefox driver It would be nice if Capybara::Screenshot looked up the adapter code for the current driver based on Does that sound reasonable to you guys? If so, here's a MR; please merge. 😄 |
I am having the issue with selenium. If I set
|
In Selenium However, note that it only is supported in Firefox. |
As I see full page screenshots are working also using Selenium with Firefox ( |
I am using capybara-selenium w/ Chrome headless. The screenshots that are saved on failure are not getting the entire page. The error I'm having is farther down on the page than what is shown in the saved PNG file. Is there some way to configure things to capture the entire page or to take an image that is positioned relative to the last successful focus from capybara?
The text was updated successfully, but these errors were encountered: