Module: Helpers::Screenshot
- Included in:
- ImageDiff::PNGSnapshot
- Defined in:
- lib/helpers/screenshot.rb
Overview
Screenshot helper
Instance Method Summary collapse
- #fullpage ⇒ Object
- #fullpage_height ⇒ Object
- #fullpage_screenshot(filename) ⇒ Object
- #resize_window(width, height) ⇒ Object
- #screenshot(filename) ⇒ Object
Instance Method Details
#fullpage ⇒ Object
14 15 16 17 |
# File 'lib/helpers/screenshot.rb', line 14 def fullpage size = Capybara.page.current_window.size resize_window(size[0], fullpage_height) end |
#fullpage_height ⇒ Object
10 11 12 |
# File 'lib/helpers/screenshot.rb', line 10 def fullpage_height Capybara.page.evaluate_script(%(document.documentElement.offsetHeight + 100;)) end |
#fullpage_screenshot(filename) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/helpers/screenshot.rb', line 19 def fullpage_screenshot(filename) size = Capybara.page.current_window.size resize_window(size[0], fullpage_height) screenshot(filename) resize_window(size[0], size[1]) end |
#resize_window(width, height) ⇒ Object
6 7 8 |
# File 'lib/helpers/screenshot.rb', line 6 def resize_window(width, height) Capybara.page.driver.browser.manage.window.resize_to(width, height) end |
#screenshot(filename) ⇒ Object
26 27 28 |
# File 'lib/helpers/screenshot.rb', line 26 def screenshot(filename) Capybara.page.save_screenshot(filename) end |