The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To take a website screenshot in Ruby, use Ferrum to control Chrome or Chromium: open a browser, navigate to a URL, save the rendered page, and close the browser. Ferrum is the direct choice for a standalone Ruby script; use Cuprite when the screenshot belongs in a Capybara test suite. Both approaches rely on a browser engine rather than Ruby drawing the page itself.
Choose the Ruby screenshot approach
The right setup depends on where the capture belongs and whether you can run a local browser:
- Standalone script or direct automation: Ferrum gives Ruby code a high-level interface to Chrome through the Chrome DevTools Protocol. Its project describes it as a Ruby API to Chrome that does not require Selenium, WebDriver, or ChromeDriver. See the Ferrum project README.
- Capybara feature or system tests: Cuprite is a Capybara driver built on Ferrum. It is the natural route when the rest of the test suite already uses Capybara. See the Cuprite README.
- Existing Selenium suite: Selenium with headless Chrome may fit an established Selenium setup, but the available source does not establish current Ruby-specific setup instructions. Verify the exact driver and browser configuration against current Selenium documentation before using it.
- No locally managed browser: A hosted screenshot API moves browser installation and execution to a service. Compare its rendering options, authentication, privacy, limits, and price against your requirements. No comparative speed or reliability figures are established here.
For most Ruby scripts that need local control over browser navigation and capture settings, start with Ferrum.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Install Ferrum and make Chrome available
Ferrum controls Chrome; the browser binary is a separate runtime requirement. Add the gem using your project’s normal dependency process (for example, include gem "ferrum" in the Gemfile and run bundle install). Then install Chrome or Chromium in the environment that will run the script.
#1 Best Overall
Ferrum’s project documentation describes finding the browser on PATH or through BROWSER_PATH, and also allows setting the executable path in browser options. If Chrome is installed somewhere nonstandard, configure the path explicitly using the option supported by the Ferrum version you install. Check the project’s current documentation for version-specific installation and browser options: Ferrum README.
Capture a basic viewport screenshot
This minimal script opens a page and saves the visible browser viewport as a PNG:
require "ferrum"
browser = Ferrum::Browser.new
begin
browser.go_to("https://example.com")
browser.screenshot(path: "page.png")
ensure
browser.quit
end
Replace https://example.com with the page you need and ensure the process can reach it. The ensure block closes Chrome even if navigation or capture raises an error; this matters for repeat runs and long-lived workers, where abandoned browser processes can consume resources.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →The short documented flow is to create a browser, call go_to, call screenshot, then call quit. The RubyCDP introduction shows that navigate/capture/quit pattern as well: RubyCDP introduction.
Rank #2
Choose what to capture and how to save it
Ferrum’s screenshot implementation documents output and capture controls. Use one capture mode per call: some combinations are ignored, and a selector takes precedence over an area.
| Need | Option or pattern | What it does |
|---|---|---|
| Save an image to disk | path: "page.png" |
Writes the screenshot to the given path. The API can also return Base64 data. |
| Choose an image format | format: "png", "jpeg", "jpg", or "webp" |
PNG is the default; JPEG/JPG and WebP are also documented. |
| Capture the full document | full: true |
Captures the full page instead of only the viewport. A very long page can produce a very tall image, so check the result on the actual page. |
| Capture one element | selector: "main" |
Captures the element matched by the CSS selector. |
| Capture a rectangular area | area: { x: 0, y: 0, width: 800, height: 600 } |
Captures the specified coordinate rectangle. |
| Adjust output scale | scale: 2 |
Controls screenshot scale. Consult Ferrum’s current API documentation for accepted values and behavior. |
| Set JPEG quality | quality: 85 |
Quality is documented as meaningful for JPEG output. |
| Set the background | background_color: "#ffffff" |
Provides a background-color override. |
Check the exact option signatures against the installed Ferrum release before relying on less common settings. The implementation documents the options and their interactions: Ferrum screenshot implementation.
Full-page capture
browser.screenshot(path: "full-page.png", full: true)
Full-page mode uses the document dimensions rather than stopping at the visible viewport. It is useful for page archives and visual review, but a long document can create a large image. Check captures with sticky headers, long feeds, or content that loads as you scroll; verify the output using the specific browser and site you deploy against.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Capture a CSS-selected element
browser.screenshot(path: "main.png", selector: "main")
Choose a selector that identifies one intended element. If the selector does not match the rendered page, the capture cannot target the desired region; inspect the page’s markup and selector before changing to a full-page or viewport capture.
Capture a coordinate area
browser.screenshot(
path: "region.png",
area: { x: 0, y: 0, width: 800, height: 600 }
)
Coordinates describe a rectangle rather than a DOM element, so this is useful when the region is defined by position and dimensions. Do not combine area with selector expecting both to apply: the selector takes precedence. Likewise, the documented interaction says full-page capture combined with selector or area is ignored; make separate calls for separate capture modes.
Rank #3
Pick a format and quality deliberately
PNG is the default and is suitable when you want the default lossless-style output. Use JPEG or WebP where those formats fit your downstream workflow; set quality only when using JPEG, since the documentation identifies it as meaningful for JPEG. Confirm the resulting file extension and format agree.
Use Cuprite for Capybara tests
Cuprite wraps Ferrum as a Capybara driver, so it is appropriate when screenshots are part of browser-driven application tests rather than a separate one-off script. Its README shows adding the gem to the test group, selecting :cuprite as the JavaScript driver, and registering a driver with a window size. Follow the configuration for your installed Cuprite and Capybara versions in the Cuprite README.
For Docker, Cuprite’s README calls out a no-sandbox browser option. That is a deployment-specific setting, not a universal default: review the current project and environment security guidance before enabling it. Do not copy container-specific configuration into a general-purpose production browser process without understanding its security implications.
Or skip the browser setup
If you do not want to install and maintain Chrome for a Ruby capture workflow, ScreenshotNeo offers a website screenshot API and MCP server. One GET request returns an image or PDF. Its cookie/consent handling, popup and chat-widget removal can be turned off step by step; responses identify whether a page was clean and whether the request was billed. AI agents can use its MCP tools for screenshots, page information, and PDF capture. See ScreenshotNeo and the API documentation.
Rank #4
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
Replace YOUR_API_KEY with your key and change the target URL. The response is saved as shot.webp. ScreenshotNeo says bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, while clean shots are billed. The free tier includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a credit card.
Recommended Free Tools
Troubleshoot common failures
Ferrum cannot find Chrome or Chromium
Likely cause: the browser is missing, not on PATH, or installed at a location Ferrum does not discover. Fix: install a compatible Chrome/Chromium binary, expose it on PATH or set BROWSER_PATH, or configure the executable path in Ferrum’s browser options. Check the installed version’s documentation for the exact option.
The script opens a browser but the screenshot is missing
Likely cause: navigation or screenshot raised an exception before the output was written, or the path is not writable. Fix: retain the exception output, check that the process has write access to the destination directory, and use an absolute path while diagnosing. Keep cleanup in an ensure block so a failed capture does not leave Chrome running.
Best Value
The capture contains only the visible portion of the page
Likely cause: the default capture is viewport-sized. Fix: request full: true when the whole document is needed, or use selector or area for a specific region.
The element or rectangle is not what you expected
Likely cause: a selector did not identify the intended element, a coordinate rectangle was based on the wrong dimensions, or incompatible capture options were combined. Fix: validate the selector and coordinates against the rendered page, then use only one of full-page, selector, or area mode for a given screenshot.
Chrome fails in a container
Likely cause: the container lacks required browser setup or the browser’s sandbox configuration does not fit the environment. Fix: verify the container’s browser installation and consult Cuprite’s current Docker guidance. Its README mentions no-sandbox; assess the security trade-off for your deployment rather than treating it as a blanket setting.
Operational considerations
- Browser lifecycle: close each Ferrum browser in cleanup code, especially in batch scripts or workers. Repeatedly creating browsers without quitting them can leave processes consuming memory and CPU.
- Page readiness: a successful navigation call does not by itself guarantee that every visual element you expect has finished changing. If the target page uses delayed or dynamic content, confirm the page state before capture using the controls supported by your installed Ferrum release.
- Image size: full-page screenshots of long documents can be very tall. Consider whether a viewport, a single element, or a cropped area better serves the task, and check output dimensions before storing or transmitting large files.
- Cost and reliability: a local browser avoids per-shot API billing but puts browser installation, upgrades, process management, and runtime capacity on your application. A hosted service transfers browser operations outside your process but requires review of its privacy, request limits, billing rules, and rendering behavior. No verified measurements here establish one route as faster or more reliable.
- Repeatability: browser and page content can change between runs. For visual tests, keep viewport and capture mode consistent and validate against the same environment you intend to run in.
Frequently Asked Questions
Does Ruby take screenshots without a browser?
Not with the Ferrum workflow described here. Ferrum drives Chrome or Chromium to render the page and capture its pixels.
Can Ferrum save a screenshot as WebP?
Yes. Ferrum’s documented format options include WebP, along with PNG and JPEG/JPG.
Should I use Ferrum or Cuprite?
Use Ferrum for direct browser automation in a standalone script; use Cuprite when the capture belongs in a Capybara test suite.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteQuick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

