Skip to content

[🐛 Bug]: When taking a screenshot fails, the resulting NameError is misinterpreted as a lack of driver support for screenshots #12799

@DanielHeath

Description

@DanielHeath

What happened?

Chromedriver sometimes returns {value: null} when you GET /session/<id>/screenshot instead of returning a string. I think that's probably a chromedriver bug.

In the selenium ruby bindings, in lib/selenium/webdriver/common/takes_screenshot.rb , any NameError is treated as "driver does not support screenshots".

When nil.unpack1('m') is called (because a null value was returned from chromedriver), this is reported as "driver does not support screenshots. This makes diagnosing the actual issue significantly more difficult!

How can we reproduce the issue?

Use chromedriver

Load a page with an iframe

Switch to the iframe

Take a screenshot

Relevant log output

[53, 62] in /home/daniel/.gem/ruby/3.2.2/gems/selenium-webdriver-4.12.0/lib/selenium/webdriver/common/takes_screenshot.rb
   53:         when :base64
   54:           full_page ? full_screenshot : screenshot
   55:         when :png
   56:           as = screenshot_as(:base64, full_page: full_page)
   57:           debugger unless as
=> 58:           as.unpack1('m')
   59:         else
   60:           raise Error::UnsupportedOperationError, "unsupported format: #{format.inspect}"
   61:         end
   62:       rescue NameError
(byebug) as
nil
(byebug) screenshot_as(:base64, full_page: full_page).length
253940

Operating System

Ubuntu

Selenium version

4.12.0 ruby

What are the browser(s) and version(s) where you see this issue?

Chrome 115

What are the browser driver(s) and version(s) where you see this issue?

Chromedriver 115

Are you using Selenium Grid?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-rbRuby BindingsI-defectSomething is not working as intendedJ-awaiting answerQuestion asked of user; a reply moves it to triage again

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions