Skip to content

Commit

Permalink
[rb] explicitly check for whether driver supports full page screensho…
Browse files Browse the repository at this point in the history
…ts to error (#12799)
  • Loading branch information
titusfortner committed Jan 21, 2024
1 parent 24d88d7 commit 2f1f779
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rb/lib/selenium/webdriver/common/takes_screenshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def save_screenshot(png_path, full_page: false)
# @api public

def screenshot_as(format, full_page: false)
if full_page && !respond_to(:full_page)
raise Error::UnsupportedOperationError, "Full Page Screenshots are not supported for #{inspect}"
end

case format
when :base64
full_page ? full_screenshot : screenshot
Expand All @@ -57,8 +61,6 @@ def screenshot_as(format, full_page: false)
else
raise Error::UnsupportedOperationError, "unsupported format: #{format.inspect}"
end
rescue NameError
raise Error::UnsupportedOperationError, "Full Page Screenshots are not supported for #{inspect}"
end
end # TakesScreenshot
end # WebDriver
Expand Down

2 comments on commit 2f1f779

@DanielHeath
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be respond_to? rather than respond_to?

@titusfortner
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Fixed it in a later commit after it broke the build.

Please # to comment.