0

I want to capture full webpage screenshot in chrome browser using ruby selenium. I am using Rspec testing framework. save_screenshot method captures screenshot only for visible area. I have gone through the following link,

How to take a screenshot of a full browser page and its elements using selenium-webdriver/capybara in Ruby?

But I don't want to use window resizing or watir gem. Is there any other way or gem to achieve same.

Tapas Mahato
  • 23
  • 10

2 Answers2

0

1) You can use https://github.com/samnissen/watir-screenshot-stitch where

  • Directly employing geckodriver's new full page screenshot functionality (only on Firefox).
  • Screenshot stitching, paging down a given URL by the size of the viewport, capturing screenshots and adjoining them.
  • Employing a bundled html2canvas script against the page to generate a png from a canvas element.

2) or use native instrument for your OS - https://paulhammond.org/webkit2png
In code will look like this
webkit2png https://stackoverflow.com/questions/60728482/can-anyone-suggest-how-to-take-screenshot-of-full-webpage-using-ruby-selenium

where:
- main command - webkit2png
- link page - all else

Vitalii
  • 113
  • 1
  • 1
  • 11
0

It's old question, but it doesn't hurt to post this. Use Scrot to take screenshot, and later make gif. Since OP only want screenshots, command would be:

require 'screenscrot'
@screen = ScreenScrot.new
@screen.capture(:all)

On linux:

sudo apt install scrot -y && gem install screenscrot
alx
  • 1