Retina screenshots with Ruby and Selenium

Install Selenium Webdrivers for Ruby

gem install webdrivers

Take a screenshot of the retina image save to file

require 'webdrivers'

options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--force-device-scale-factor=2')

driver = Selenium::WebDriver.for :chrome, options: options

driver.get "https://www.bbc.co.uk/news/business-63709754"

driver.manage.window.resize_to(480, 240)

driver.save_screenshot("./retina.png")

Find out how to take a full-page screenshot with Ruby and Selenium.

We created Urlbox to make converting HTML to images easy

Learn more about our website screenshot API.