Class: TRMNLP::Screenshot
- Inherits:
-
Object
- Object
- TRMNLP::Screenshot
- Defined in:
- lib/trmnlp/screenshot.rb
Instance Method Summary collapse
- #call(html:, width:, height:) ⇒ Object
-
#initialize(pool:, viewport_timeout: 5) ⇒ Screenshot
constructor
A new instance of Screenshot.
Constructor Details
#initialize(pool:, viewport_timeout: 5) ⇒ Screenshot
Returns a new instance of Screenshot.
10 11 12 13 |
# File 'lib/trmnlp/screenshot.rb', line 10 def initialize(pool:, viewport_timeout: 5) @pool = pool @viewport_timeout = end |
Instance Method Details
#call(html:, width:, height:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/trmnlp/screenshot.rb', line 15 def call(html:, width:, height:) attempts = 0 begin @pool.with_driver { |driver| render(driver, html, width, height) } rescue Selenium::WebDriver::Error::TimeoutError, Selenium::WebDriver::Error::WebDriverError attempts += 1 retry if attempts <= 1 raise end end |