Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure Chrome’s download preferences with an absolute, writable directory, run Chrome with --headless=new, and wait for the file to finish before quitting the driver. ChromeDriver starts a download but does not wait for its completion, so a reliable Ruby script must detect a completed file—or use Selenium only to obtain the download URL and cookies, then transfer the bytes with an HTTP client.

What you need before writing the script

Use compatible browser, driver and Selenium versions

Keep Chrome and ChromeDriver on the same major version. For Chrome 115 and later, Chrome and ChromeDriver releases for each channel are distributed through the Chrome for Testing availability dashboard and its JSON endpoints. Selenium supports Chrome 75 and later, but that broad compatibility statement does not replace checking the current major-version match.

Selenium Manager has been shipped with Selenium since version 4.6. When no driver is supplied, it is the normal fallback for locating or managing one. A manually installed driver can still be placed on PATH or supplied through Selenium’s service configuration when your CentOS environment requires pinned binaries.

CentOS is a platform constraint, not a single package recipe

The exact browser libraries and repository steps depend on your CentOS release and whether you use Google Chrome, Chromium, or an internally packaged build. Do not copy a yum or dnf recipe without checking that release’s supported repositories and system libraries. The Ruby and Selenium code below is distribution-neutral once a working Chrome/ChromeDriver pair is available.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
HP OmniBook 3 17.3 inch Laptop PC, FHD Display, AMD Ryzen 3 30, 8 GB RAM, 512 GB SSD, AMD Radeon 610M Graphics, Windows 11 Home, Mica Silver, 17-dp0199nr
  • FULL HD IPS DISPLAY - Enjoy vibrant, crystal-clear images with 178-degree wide-viewing angles
  • AMD RYZEN 3 30 PROCESSOR - Everyday performance you can count on; Multitask, stream, game casually, and edit photos smoothly with responsive power and vibrant HDR visuals
  • ENJOY UP TO 14 HOURS AND 15 MINUTES OF BATTERY LIFE - HP Fast Charge restores battery from 0 to 50% in approximately 45 minutes
  • AMD RADEON 610M GRAPHICS - Experience smooth entertainment; Built for streaming and multitasking, enjoy realistic visuals and efficient performance for work and play
  • STORAGE AND MEMORY - 512 GB PCIe NVMe M.2 SSD offers fast speed and efficient storage; and 8 GB LPDDR5 RAM memory boosts performance with higher bandwidth

Choose an ordinary download directory

Pass a unique, absolute Linux path that the account running Ruby can create and write. ChromeDriver documents a Linux-specific restriction on certain locations, including home-directory paths; the forbidden list can change. A dedicated temporary directory such as /tmp/chrome-download-... is safer than a home or desktop directory. Relative paths may not work reliably.

Configure headless Chrome to save downloads

The following script uses the Selenium Ruby bindings’ documented Selenium::WebDriver::Chrome::Options and add_preference pattern. It creates a unique directory for each run, suppresses the save prompt, clicks a download link, and waits until a non-temporary file has a stable size.

require 'selenium-webdriver'
require 'tmpdir'
require 'timeout'

# A unique, absolute directory avoids collisions between parallel jobs.
download_dir = Dir.mktmpdir('chrome-download-')

options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless=new')
options.add_preference(:download,
  prompt_for_download: false,
  default_directory: download_dir
)

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

begin
  driver.navigate.to('https://example.test/downloads')

  # Replace this selector with the link or button in your application.
  driver.find_element(css: 'a[data-download]').click

  deadline = Time.now + 90
  completed_file = nil
  previous_size = nil
  stable_reads = 0

  until Time.now > deadline
    candidates = Dir.children(download_dir)
      .reject { |name| name.end_with?('.crdownload', '.tmp', '.part') }
      .map { |name| File.join(download_dir, name) }
      .select { |path| File.file?(path) }

    if (candidate = candidates.max_by { |path| File.mtime(path) })
      size = File.size(candidate)
      if size > 0 && size == previous_size
        stable_reads += 1
      else
        stable_reads = 0
      end
      previous_size = size

      if stable_reads >= 2
        completed_file = candidate
        break
      end
    end

    sleep 0.5
  end

  raise Timeout::Error, "download did not finish in #{download_dir}" unless completed_file
  puts "Downloaded #{completed_file} (#{File.size(completed_file)} bytes)"
ensure
  driver.quit
  # Validate or move completed_file before deleting download_dir.
end

Replace the example URL and selector with the page you control. In production, also verify the filename, extension, size range, and—when applicable—a checksum or archive listing. If a site can trigger several downloads, identify the expected filename rather than accepting the newest file.

Why waiting for completion is mandatory

Chrome writes an in-progress download under a temporary name, commonly ending in .crdownload. ChromeDriver does not wait for that operation to finish. Calling driver.quit immediately after a click can therefore leave a partial file or no usable file at all. Polling for the expected output and confirming that its size remains unchanged for multiple reads avoids the most common race.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a timeout and preserve diagnostics

A finite timeout prevents a hung page from blocking a CI job forever. On timeout, retain the directory long enough to inspect temporary files, browser logs, the current URL, and the page’s visible error. Delete the directory only after your validation and diagnostics have completed.

Rank #2
HP 14" HD Chromebook Laptop for Students, Intel Quad-Core N4120(> N4020), 4GB RAM, 64GB eMMC, WiFi, Webcam, HDMI, USB-A&C, 14 Hours Battery Life, Zoom, Chrome OS, CUE Accessories
  • Intel Celeron N4120: 4 Cores & Threads, 1.1GHz Base Clock, Up to 2.6GHz Boost Clock, 4MB Cache, Intel UHD Graphics 600. The perfect combination of performance, power consumption, and value helps your device handle multitasking smoothly and reliably with four processing cores to divide up the work.
  • 14" HD Display: 14.0-inch diagonal, HD (1366 x 768), micro-edge, anti-glare. See your digital world in a whole new way. Enjoy movies and photos with the great image quality and high-definition detail of 1 million pixels.
  • Memory & Storage: 4 GB LPDDR4x & 64 GB eMMC Storage. Adequate high-bandwidth RAM to smoothly run multiple applications and browser tabs all at once. An embedded multimedia card provides reliable flash-based storage.
  • Ports:2 x USB 3.0 Type-A,1 x USB 3.0 Type-C,1 x HDMI,1 x Headphone Jack
  • Chrome OS: Chromebook is a computer for the way the modern world works, with thousands of apps. Enjoy the seamless simplicity that comes with Google Chrome and Android apps, all integrated into one laptop. It’s fast, simple, and secure.

Do not infer success from the click

A click can open a login page, return an HTML error document, be intercepted by a bot check, or be disabled by JavaScript. Treat the completed file as the success condition and inspect its content type or signature when the format matters.

When Selenium should not transfer the file

Selenium’s WebDriver API does not expose download progress. Selenium’s file-download guidance notes that clicking under browser control is possible but is less suitable for tests that must inspect downloaded bytes. A more deterministic pattern is to let Selenium locate the link and establish authentication, then download the resource with an HTTP client.

Ruby HTTP transfer with Selenium cookies

This example navigates to a page, obtains the link URL and session cookies, and streams the response to disk. It is appropriate when the browser interaction is only needed for login, redirects, or JavaScript that reveals the final URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
require 'selenium-webdriver'
require 'net/http'
require 'uri'

options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless=new')
driver = Selenium::WebDriver.for(:chrome, options: options)

begin
  driver.navigate.to('https://example.test/account/files')
  href = driver.find_element(css: 'a[data-download]').attribute('href')

  cookie_header = driver.manage.all_cookies
    .map { |cookie| "#{cookie[:name]}=#{cookie[:value]}" }
    .join('; ')

  uri = URI.parse(href)
  request = Net::HTTP::Get.new(uri)
  request['Cookie'] = cookie_header unless cookie_header.empty?
  request['User-Agent'] = driver.execute_script('return navigator.userAgent')

  Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
    http.request(request) do |response|
      response.value                 # raises for 4xx/5xx responses
      File.open('/tmp/result.bin', 'wb') do |file|
        response.read_body { |chunk| file.write(chunk) }
      end
    end
  end
ensure
  driver.quit
end

Forward only the cookies and headers the endpoint needs. Some applications require an Authorization header, a CSRF token, or a referer; obtain those from the page’s documented flow rather than blindly copying every browser header. The HTTP client gives you status codes, headers, streaming, and direct content validation that WebDriver does not provide.

Headless mode details on current Chrome

Selenium’s Chrome documentation lists --headless=new as the current headless argument. Chrome’s headless implementation now shares the regular Chrome implementation. Beginning with Chrome 132, the old implementation is available separately as the chrome-headless-shell binary; it is not the normal Chrome executable. Unless you specifically need that shell, use the current Chrome binary with --headless=new.

Rank #3
Sale
AKCHART 15.6'' AI Laptop with Office 365 12GB RAM 256GB SSD Win 11 Laptops
  • Stunning 15.6" FHD IPS Display: Experience crisp 1920x1080 resolution on this 15.6 inch laptop with an IPS panel that delivers wide viewing angles and vivid colors. The narrow-bezel design maximizes screen real estate for comfortable viewing on this Win 11 laptop, whether you're studying or working.
  • Celeron J4105 Processor & 256GB SSD: Powered by a reliable Celeron J4105 processor paired with 12GB DDR4 memory and a fast 256GB M.2 SSD. This laptop computer supports SSD expansion up to 2TB and TF card expansion up to 1TB, so your storage grows with your needs. Delivers smooth multitasking for daily productivity.
  • AI-Powered Win 11 Laptop: Built-in AI features enhance your productivity with smart assistance for writing, summarizing, and task management. Pre-installed with Win 11 and includes Office 365 subscription. This student laptop is backed by 1-year warranty and 24/7 customer support.
  • All-Day 7000mAh Battery & 180° Hinge: The high-capacity 7000mAh battery keeps this laptop powered through long classes or meetings. The 180-degree lay-flat hinge lets you share your screen effortlessly during presentations. This durable laptop computer adapts to your dynamic workflow.
  • Versatile Connectivity Hub: Equipped with USB 3.2, Type-C, Mini HDMI, and 3.5mm audio jack to connect all your peripherals. Stay online anywhere with high-speed 5G WiFi and Bluetooth 4.2. This college laptop keeps you connected at home, in the library, or on the go.

Download reliability checklist

  • Use a unique absolute directory for each run and verify that the Ruby account can write to it.
  • Keep Chrome and ChromeDriver on the same major version.
  • Set prompt_for_download: false and the full default_directory.
  • Wait for the expected file, not merely for the click event.
  • Ignore temporary suffixes such as .crdownload while polling.
  • Require a stable size across more than one poll and impose a finite timeout.
  • Validate status, filename, content type, magic bytes, or checksum before using the file.
  • In parallel jobs, never share one download directory unless each job has a collision-proof filename.
  • Use the HTTP-client approach when the test’s real assertion concerns file bytes rather than the browser download UI.

Common failures and precise fixes

Chrome starts, but no file appears

Confirm that the selector clicked the intended element and that the page did not open a new tab, require a login, or display a consent or bot-check screen. Log the current URL and page title, and inspect the directory for a lingering .crdownload file. Verify the configured directory is absolute and writable.

The script finds a partial file

Do not treat directory appearance as completion. Continue polling until the temporary suffix disappears and the size is unchanged for multiple intervals. Increase the timeout for large files or slow servers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Chrome reports a session or driver error

Check the browser and driver major versions first. For Chrome 115+, obtain both from the same Chrome for Testing channel where possible, or allow Selenium Manager to resolve the driver when your environment permits it. If policy requires a fixed binary, put the matching driver on PATH or configure Selenium’s service explicitly.

The directory is ignored or Chrome refuses it

Choose a normal, dedicated directory outside the home or desktop locations called out in ChromeDriver’s Linux caveat. Pass the full path, create it before starting Chrome, and verify ownership and permissions for the account running the job.

The downloaded “file” is actually HTML

Read the response or file signature before processing it. A redirect to a login page, an authorization failure, or a bot challenge can produce a successful-looking file with the wrong content. Switch to the cookie-and-HTTP-client pattern when authentication or response inspection is central to the test.

Rank #4
HP Essential Laptop 2026, Intel CPU, 128GB Storage, Office 365, Windows 11
  • Efficient Performance for Everyday Computing: Powered by Intel N150 processor with up to 3.6 GHz Intel Turbo Boost Technology, 6 MB L3 cache, 4 cores, and 4 threads, this HP laptop delivers responsive performance for web browsing, streaming, document editing, and multitasking. Paired with 4GB LPDDR5 RAM and 128GB UFS storage, it handles daily tasks smoothly. Includes 1-year Microsoft 365 Personal subscription for Word, Excel, PowerPoint, and cloud storage to maximize your productivity.
  • 14-Inch HD Micro-Edge Display:Enjoy clear visuals on the 14-inch HD (1366 x 768) anti-glare screen with 250-nit brightness and 62.5% sRGB coverage. The micro-edge bezel delivers a 79% screen-to-body ratio in a compact design. An HP True Vision 720p HD camera with noise reduction and dual-array microphones supports clear video calls, remote work, and online learning.
  • Modern Connectivity and Wireless Technology: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.4 for seamless pairing with accessories. Versatile port selection includes 1 USB Type-C 10Gbps with DisplayPort 1.2 for external displays, 2 USB Type-A 5Gbps ports for peripherals, 1 HDMI 1.4b port, 1 headphone/microphone combo jack, and 1 multi-format SD media card reader. Connect monitors, transfer files quickly, and expand your workspace with ease.
  • All-Day Battery Life and Portable Design: Enjoy up to 11 hours of video playback, 7.5 hours of mixed usage, or 7.5 hours of wireless streaming on a single charge, perfect for students and professionals on the go. Weighing just 3.24 lb and measuring 12.76" x 8.86" x 0.71", this lightweight laptop fits easily in backpacks and bags. The stylish willow green top cover with matte finish and natural silver keyboard deck with vertical brushing pattern offer a modern, professional look.
  • AI-Enhanced Productivity: Access Microsoft Copilot instantly with the dedicated Copilot key for faster assistance. AI Noise Reduction filters background sounds and improves voice clarity during calls. Dual speakers provide clear audio, while the full-size natural silver keyboard and HP Imagepad support comfortable typing and navigation.

It works locally but fails in CI

Compare the Chrome major version, driver path, user account, writable directories, and available shared memory between environments. Print the effective download path and retain the failed run’s temporary directory. Do not assume a home-directory path exists or is permitted in a service account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, cleanup and cost considerations

Browser-managed downloads launch a full browser and are best when navigation, JavaScript, authentication, or the actual download gesture is under test. They cost more CPU and startup time than an HTTP request. Once you have a stable authenticated URL, streaming with an HTTP client avoids rendering overhead and makes retries and byte-level assertions easier.

Use one browser session for related navigation, but isolate download directories between parallel workers. Move a validated file to durable storage before removing the temporary directory. For large artifacts, stream directly to disk instead of buffering the response in memory.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server, not a file-download replacement for authenticated binary artifacts. It is useful when the goal is a rendered image or PDF of a page rather than the page’s downloadable payload. One GET request returns PNG, JPEG, WebP, or PDF; the API accepts the URL and access key as query parameters.

cURL (see the ScreenshotNeo documentation for all options):

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
HP 14‘’ Laptop, 2027 Edition, Intel N150 CPU, 4GB RAM, 128GB SSD, Copilot AI, 1TB Cloud Storage, Win 11 with Microsoft 365
  • Designed for mobility with a slim 0.71-inch profile and lightweight, making it easy to carry between home, office
  • 【Versatile Connectivity】Stay connected with multiple ports including USB 3.0 Type-C, USB 3.0 Type-A, HDMI, and a headphone/mic combo jack, with Wi-Fi and Bluetooth for seamless wireless networking.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

Before capture, ScreenshotNeo can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed as clean shots, and response headers identify the page verdict and billing state. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools to Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots, and every feature is included on every plan. Create a free ScreenshotNeo account.

Frequently asked questions

Frequently Asked Questions

Can I use a relative download path?

Use an absolute path. ChromeDriver’s documentation warns that relative paths may not work reliably, and Linux locations such as home directories can be disallowed.

Does Selenium provide a download-progress event?

No. WebDriver does not expose download progress; poll the filesystem or transfer the resource with an HTTP client after obtaining the URL and cookies.

Is --headless=new still the right argument?

It is the current Selenium Chrome option. Since Chrome 132, the old headless implementation is a separate chrome-headless-shell binary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should every CentOS installation use the same Chrome package commands?

No. Browser packages and supported libraries vary by CentOS release. Verify the release-specific official package and browser support before installing anything.

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.