From 2f1f779bf423b10bd80d3a010dbde10b637a41db Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sun, 21 Jan 2024 09:12:48 -0600 Subject: [PATCH] [rb] explicitly check for whether driver supports full page screenshots to error (#12799) --- rb/lib/selenium/webdriver/common/takes_screenshot.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rb/lib/selenium/webdriver/common/takes_screenshot.rb b/rb/lib/selenium/webdriver/common/takes_screenshot.rb index ffac7a83c2367..598e454579792 100644 --- a/rb/lib/selenium/webdriver/common/takes_screenshot.rb +++ b/rb/lib/selenium/webdriver/common/takes_screenshot.rb @@ -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 @@ -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