(Btw i am not JS programmer, its like guessing game for me :))
Inspired by #285 (@route said that maybe we could try to pass area arguments right to the method)
so i just changed method screenshot_options like this
require "ferrum"
module Ferrum
class Page
module Screenshot
private
def screenshot_options(path = nil, format: nil, scale: 1.0, **options)
screenshot_options = {}
format, quality = format_options(format, path, options[:quality])
screenshot_options.merge!(quality: quality) if quality
screenshot_options.merge!(format: format)
clip = if options[:rect]
options[:rect].merge(scale: scale)
else
area_options(options[:full], options[:selector], scale)
end
screenshot_options.merge!(clip: clip) if clip
screenshot_options
end
end
end
end
browser = Ferrum::Browser.new(headless: false, timeout: 120)
vnm_url = "secret_url"
browser.goto(vnm_url)
captcha_el = browser.at_css(".captcha")
captcha_el.scroll_into_view
my_own_rect = captcha_el.evaluate("(function(el) { return { x: el.offsetLeft, y: el.offsetTop, width: el.offsetWidth, height: el.offsetHeight } })(this)")
browser.screenshot(rect: my_own_rect, path: "captcha.png")
Hello,
So i have this script
And i saw that i only have blank image with white background
So my workaround is using
browser.network.intercept
Its like
But i am curious :=) I calculated the position of the image with different method
(Btw i am not JS programmer, its like guessing game for me :))
Inspired by #285 (@route said that maybe we could try to pass area arguments right to the method) so i just changed method
screenshot_options
like thisAnd seems now i can get the image