Total Blog Views: 54
Blog Status: publish
Created By: swazahmad Created at: 09-04-2021
Tags: ruby on rails screen shots in ruby on rails capture image in ruby on rails visit website and capture Image in ruby on rails
Install gem by
$ gem install screencap
This command will install screencap on your machine
If you need to use gem from your Rails application then you need to add it to the Gemfile
gem 'screencap'
After adding to Gemfile, bundle
bundle
This command will ensure the availability of your gem your Ruby On Rails application
Usage
Using screencap gem to capture screenshots is fairly easy. The following code will help you capture screenshots with ruby -
require 'screencap' fetcher_object = Screencap::Fetcher.new('https://www.shadbox.com') screenshot = fetcher_object.fetch
The fetch method supports various options as given below -
screenshot = fetcher_object.fetch( output: '~/public/file-name.png', # optional parameters: div: '.class-name', # CSS selector width: 500, # Width of Screenshot - Viewport height: 420, # Height of Screenshot - Viewport top: 0, left: 0, width: 100, height: 100 # Area to capture screenshot of)
I Hope, the above tutorial helps you to capture screenshots with Ruby. Please feel free to comment down below.
we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.
© Copyright Shadbox. All Rights Reserved
Rate Blog :
Share on :
Do you have any blog suggestion? please click on the link