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

Use the playwright-ruby-client gem as a Ruby control layer over Playwright’s Node runtime. Install Node.js, install the exact playwright-core version compatible with your gem, download browser binaries, then launch Chromium (or connect to a separately running Playwright server). The same page-navigation and locator workflow supports JavaScript-heavy scraping and browser checks, but selectors, access rules and assertions remain specific to the site and test framework you choose.

What the Ruby Playwright stack contains

The Ruby package is playwright-ruby-client, a client binding rather than a complete browser installation. The project README documents a dependency chain of Ruby code, Node.js, a matching playwright-core release and Playwright browser binaries. The project source is on GitHub.

  • Ruby: your scraper or test code and the playwright-ruby-client gem.
  • Node.js: runs the Playwright command-line component used by the Ruby client.
  • playwright-core: the version that matches the gem’s compatibility constant.
  • Browser binaries: Chromium, Firefox or WebKit installed by Playwright.

RubyGems currently lists version 1.62.0 (release dated August 1, 2026) and a minimum Ruby version of 2.4. The registry page available for the project is RubyGems; check the live gem and README before pinning commands because compatibility and release numbers change.

Install Ruby, Node.js and the compatible browser runtime

  1. Add the gem. In your application’s Gemfile, add gem 'playwright-ruby-client', then run bundle install.
  2. Install Node.js. Use a supported current Node.js release in the environment where the browser process will run.
  3. Read the compatibility value from the gem. The README instructs you to derive the Playwright version from Playwright::COMPATIBLE_PLAYWRIGHT_VERSION, rather than guessing a version.
  4. Install that exact core package. For example, substitute the value printed by the following command for VERSION:
bundle exec ruby -e "require 'playwright'; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION"

Use the resulting value with npm:

npm install --global playwright-core@VERSION

Install the browser binaries with the Playwright CLI supplied by that package:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
playwright-core install chromium

If your environment does not put the global executable on PATH, install locally instead and use the resulting executable path in your Ruby configuration. Keep the gem, playwright-core and browser versions aligned; mismatches are a common cause of launch failures.

Launch Chromium from Ruby

The README’s local-launch pattern configures playwright_cli_executable_path, creates a client, launches Chromium and opens a page. This complete example also closes resources in an ensure block.

require 'playwright'

cli_path = ENV.fetch('PLAYWRIGHT_CLI_PATH', 'playwright-core')

Playwright.playwright_cli_executable_path = cli_path
playwright = Playwright.create
browser = playwright.chromium.launch(headless: true)
page = browser.new_page

begin
  page.goto('https://example.com', wait_until: 'domcontentloaded')
  puts page.title
  puts page.locator('h1').inner_text
ensure
  browser.close
  playwright.stop
end

Use an absolute path when your service manager, container or deployment platform has a restricted PATH. Keep the browser headless on servers unless you specifically need a visible desktop session.

Scrape content that appears after interaction

Browser automation is useful when the data is rendered or revealed by client-side interaction. The project’s example navigates to GitHub, fills a search control, submits it, waits for result elements and prints their text. Treat those GitHub selectors as examples only: inspect the target page and replace them with stable locators.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Playwright.playwright_cli_executable_path = ENV.fetch('PLAYWRIGHT_CLI_PATH', 'playwright-core')
playwright = Playwright.create
browser = playwright.chromium.launch(headless: true)
page = browser.new_page

begin
  page.goto('https://github.com/search', wait_until: 'domcontentloaded')
  page.get_by_role('textbox', name: 'Search').fill('ruby playwright')
  page.get_by_role('button', name: 'Search').click

  page.locator('[data-testid="results-list"]').wait_for
  titles = page.locator('[data-testid="results-list"] h3').all_inner_texts
  titles.each { |title| puts title }
ensure
  browser.close
  playwright.stop
end

Prefer semantic roles, labels and stable data attributes over deeply nested CSS paths. Wait for the element or state that proves the result is ready, not an arbitrary sleep. For each site, handle pagination, consent dialogs, rate limits and authentication according to its terms and access controls. Browser automation is not automatically permitted for every target.

Use the same browser workflow for testing

A UI check normally follows the same sequence: create a context, navigate, perform an action, wait for the expected state and inspect the result. The reviewed project documentation confirms browser navigation and interaction, but does not establish a built-in Ruby test runner, assertion library or official integration with RSpec, Minitest or another framework.

require 'playwright'

Playwright.playwright_cli_executable_path = ENV.fetch('PLAYWRIGHT_CLI_PATH', 'playwright-core')
playwright = Playwright.create
browser = playwright.chromium.launch(headless: true)
page = browser.new_page

begin
  page.goto('https://your-app.example/login', wait_until: 'domcontentloaded')
  page.get_by_label('Email').fill(ENV.fetch('TEST_EMAIL'))
  page.get_by_label('Password').fill(ENV.fetch('TEST_PASSWORD'))
  page.get_by_role('button', name: 'Sign in').click
  page.get_by_role('heading', name: 'Dashboard').wait_for
  abort 'Dashboard did not load' unless page.title.include?('Dashboard')
ensure
  browser.close
  playwright.stop
end

Wrap this code in the setup and teardown hooks of your chosen Ruby test framework, and use that framework’s assertions and reporting. Verify any third-party adapter independently; do not assume the gem supplies one.

Choose local launch or a separate Playwright server

Arrangement Use it when What you operate
Local launch The Ruby process can install browsers and create child processes. Ruby, Node.js, playwright-core and browser binaries in the same environment.
Remote Playwright server Your deployment cannot launch browsers locally, or browser execution belongs in a separate service. A separately started Playwright server plus the Ruby client connection.

The README documents starting playwright-core run-server separately and connecting with Playwright.connect_to_browser_server. In this mode the CLI executable path is not required for the connection call.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
# In the browser-service process
playwright-core run-server
require 'playwright'

playwright = Playwright.connect_to_browser_server(ENV.fetch('PLAYWRIGHT_SERVER_URL'))
browser = playwright.chromium
  .launch(headless: true)
page = browser.new_page

begin
  page.goto('https://example.com')
  puts page.title
ensure
  browser.close
  playwright.stop
end

The project documents the connection pattern, not a guarantee that every hosting provider or network topology will work without additional firewall, authentication or process-management configuration. There is no source-backed performance, price or reliability comparison between the two arrangements.

Make scraping resilient

Wait for the state you need

Use navigation conditions such as domcontentloaded, then wait for a result locator, a URL change or a page-specific state. Fixed delays can be either too short (flaky) or unnecessarily slow.

Control context data

Create separate browser contexts for independent sessions. Supply cookies, headers or an authenticated storage state only when you are authorized to do so. Avoid logging credentials or session tokens.

Handle empty and partial results

  • Check that the expected result container exists before reading text.
  • Record the URL and a useful error message when a selector is absent.
  • Detect login pages, consent screens and bot challenges instead of saving them as data.
  • Close pages, browsers and Playwright clients even when extraction raises an exception.

Respect the target

Follow the site’s terms, robots guidance where applicable, authentication rules and rate limits. Do not present a successful browser interaction as permission to collect data.

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

Troubleshooting common failures

“Executable not found” or a launch error

Usually Node.js, playwright-core, the browser binary or the CLI path is missing. Confirm node --version, rerun the compatibility query, install the matching package and browser, then set Playwright.playwright_cli_executable_path to an absolute executable path.

Protocol or version mismatch

A gem paired with an arbitrary Playwright version can fail during startup. Reinstall the exact version printed by Playwright::COMPATIBLE_PLAYWRIGHT_VERSION; do not copy a version from an unrelated example.

Selector timeout

The selector may be wrong, the page may still be rendering, or a consent/login layer may be covering the control. Inspect the live DOM, choose a role, label or stable attribute, and wait for the actual result state.

Works locally but not in deployment

Compare Node and Ruby versions, executable paths, installed browser files, sandbox permissions and outbound network access. In a restricted environment, move browser execution to the documented server mode and connect from Ruby.

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

Scraped text is blank or incomplete

Read the locator after the relevant interaction has completed, and verify that you selected the intended frame or element. Save an HTML snapshot or screenshot during diagnosis, while ensuring sensitive data is not retained.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For a one-off page image or an automated capture pipeline, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request returns PNG, JPEG, WebP or PDF. The API accepts custom waits, JavaScript, headers, cookies, device settings, full-page capture and many other options; its parameter names are compatible with those used by other screenshot APIs.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for all options and response headers. Equivalent calls from other languages are:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
  • Cookie and consent banners, newsletter popups and chat widgets are removed before the shot; each cleanup step can be disabled.
  • Bot checks, blank pages, failed loads, timeouts and cache hits are not billed, and X-Page-Verdict and X-Billed headers identify the result.
  • An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is on every plan.

Create a free ScreenshotNeo account to get the 1,000 monthly screenshots without a card.

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

Ruby implementation checklist

  • Pin playwright-ruby-client in your Gemfile and record the Ruby version.
  • Derive and install the matching playwright-core release.
  • Install the browser binary in the same image or host that launches it.
  • Set an explicit CLI path in production.
  • Use semantic, site-specific locators and state-based waits.
  • Close browser resources in all success and failure paths.
  • Choose remote server mode only when you can operate and secure that separate process.
  • Keep scraping within the target site’s rules and your authorization.

Frequently Asked Questions

Does playwright-ruby-client install Chromium automatically?

No. It is a Ruby binding. You install Node.js, the compatible playwright-core release and the browser binaries separately.

Can I use Playwright in Ruby without Node.js?

The documented Ruby workflow depends on the Playwright Node CLI. A separate Playwright server can host that runtime while Ruby connects to it.

Is Playwright a complete Ruby testing framework?

The project documents browser control, not a built-in Ruby test runner or assertion library. Integrate the page workflow with the Ruby framework your team selects.

Which browser should I install first?

Chromium is the browser used in the documented launch examples. Install Firefox or WebKit as needed for your coverage.

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

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.