Module: Ferrum::Page::Screenshot
- Included in:
- Ferrum::Page
- Defined in:
- lib/ferrum/page/screenshot.rb
Instance Method Summary collapse
Instance Method Details
#document_size ⇒ Object
28 29 30 31 32 33 |
# File 'lib/ferrum/page/screenshot.rb', line 28 def document_size evaluate <<~JS [document.documentElement.offsetWidth, document.documentElement.offsetHeight] JS end |
#pdf(**opts) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ferrum/page/screenshot.rb', line 14 def pdf(**opts) path, encoding = (**opts) = (**opts) data = command("Page.printToPDF", **).fetch("data") return data if encoding == :base64 save_file(path, data) end |
#screenshot(**opts) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/ferrum/page/screenshot.rb', line 6 def screenshot(**opts) path, encoding = (**opts) = (path, **opts) data = command("Page.captureScreenshot", **).fetch("data") return data if encoding == :base64 save_file(path, data) end |
#viewport_size ⇒ Object
22 23 24 25 26 |
# File 'lib/ferrum/page/screenshot.rb', line 22 def evaluate <<~JS [window.innerWidth, window.innerHeight] JS end |