简体   繁体   中英

Can anyone suggest how to take screenshot of full webpage using ruby selenium?

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

Is there any other way or gem to achieve same.

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM