October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

Cross-Browser Testing with Watir: A Practical Guide

Use Watir to run the same behavior-focused tests across explicitly selected browser sessions, with practical guidance on setup, remote execution, browser differences, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To test a site across browsers with Watir, keep the same behavior-focused scenarios and start a separate WebDriver session for each browser you intend to support. For example, choose Firefox with Watir::Browser.new :firefox instead of relying on the default session. Each run still needs a usable browser and WebDriver setup where that session executes.

How Watir cross-browser testing works

Watir is a Ruby interface for browser automation built on Selenium WebDriver. Watir expresses browser interactions; Selenium’s WebDriver API and protocol carry commands through a browser-specific driver to the browser. In a cross-browser suite, the reusable part is the test intent—such as signing in, submitting a form, and checking the result—while browser selection, capabilities, and environment can vary.

Watir’s session guide documents Chrome as the default and shows selecting other browsers when creating a session. Its examples include Firefox, Edge, Safari, and Internet Explorer. These are documented patterns, not a guarantee that every Watir, Ruby, browser, and driver version currently supports every combination. Check the documentation for the versions you use. Watir: Starting a Session; Selenium: Supported Browsers.

Choose a browser matrix that matches your product

There is no universal browser matrix established by the documentation. Start with the browsers and operating systems your product is expected to support, then add targets where browser-specific behavior or customer requirements make them important. Selenium’s supported-browser documentation lists browser-specific sections for Chrome, Edge, Firefox, Internet Explorer, and Safari; the presence of Internet Explorer in documentation does not make it a default choice for a new project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Include operating-system differences when they matter to your users or product requirements.
  • Decide whether each browser runs locally or on a remote machine, and identify who provisions and maintains that environment.
  • Plan for browser-specific capabilities and setup. Selenium notes that “Each browser has custom capabilities and unique features.”
  • Use the same user-facing scenarios across targets, but allow targeted configuration or assertions when a real browser difference requires them.

For browser-specific setup, consult the relevant Watir guide and verify it against your current versions: Chrome, Firefox, Edge, and Safari. These Watir pages were last updated March 12, 2021, so treat their setup details as historical guidance to recheck rather than current compatibility guarantees.

Reuse scenarios and select the browser explicitly

Centralize browser selection in test setup or configuration, then run the same scenario against each chosen browser. Watir’s documented selection pattern is to pass a browser symbol to Watir::Browser.new; omitting it opens the default browser in the session guide. A small runnable Ruby example follows. It assumes the page exposes the example elements shown; replace the URL, selectors, and expected text with those in your application.

require "watir"

browser_name = (ENV["BROWSER"] || "chrome").to_sym
browser = Watir::Browser.new(browser_name)

begin
  browser.goto "https://example.com"
  heading = browser.h1
  abort "Expected page heading" unless heading.exists?
  puts heading.text
ensure
  browser.close
end

Run it with the default browser or select another documented target through the environment:

ruby cross_browser.rb
BROWSER=firefox ruby cross_browser.rb
BROWSER=edge ruby cross_browser.rb
BROWSER=safari ruby cross_browser.rb

Environment-variable syntax and browser availability depend on the shell and operating system. The example demonstrates selection, not a guarantee that those browser symbols or environments work with every installed Watir version. Check the session guide for the version you use.

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

Set up local WebDriver sessions

A local run needs Ruby and the Watir/Selenium libraries, an installed target browser, and a compatible driver available to the WebDriver setup. Selenium describes the driver as the component that relays commands between Selenium and the browser; installation and compatibility problems can prevent session creation before a test reaches the page. See Selenium getting started and Selenium browser-driver troubleshooting.

Watir’s driver guide recommends the webdrivers gem for automatic downloads and lists drivers including ChromeDriver, GeckoDriver, Microsoft WebDriver, IEDriver, and Safari’s preinstalled safaridriver. That guide is dated March 12, 2021. Do not treat its gem recommendation or list as a verified setup recipe for current releases: check current Watir and Selenium release documentation, browser requirements, and driver compatibility before installing or changing driver management. Watir: Drivers.

Run browsers remotely when the environment calls for it

Watir documents passing a remote WebDriver URL when opening a browser session. In that arrangement, the browser and driver run on the remote machine or service, while your test connects to its endpoint. Remote execution shifts browser provisioning and session management; it does not remove the need for a valid browser session or compatible configuration.

require "watir"

remote_url = ENV.fetch("WEBDRIVER_URL")
browser = Watir::Browser.new(:firefox, url: remote_url)

begin
  browser.goto "https://example.com"
  puts browser.title
ensure
  browser.close
end

Set WEBDRIVER_URL to the remote WebDriver endpoint provided by your environment. The exact endpoint, authentication, capabilities, and session options depend on that environment. Watir’s guide names BrowserStack and Sauce Labs as examples of online service providers, but that reference does not establish their current integration details, features, or prices. Watir remote session documentation.

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

Handle browser-specific behavior without duplicating the suite

Prefer assertions about the product’s behavior rather than incidental rendering details. Keep browser-specific options near session configuration, and introduce browser-specific expectations only when the product genuinely behaves differently. Selenium explicitly notes the custom capabilities and unique features of individual browsers, so a successful run in one browser is not proof of identical behavior in another.

Setup can vary: Watir’s Firefox guide discusses profiles and preferences, while its Safari guide describes an authorization/setup step. Because these guides were last updated March 12, 2021, verify each detail against your installed browser and Watir/Selenium versions before relying on it.

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

Diagnose failures by the layer where they occur

When a run fails, first determine whether the browser session started. If it did not, investigate browser and driver setup before changing page selectors or assertions.

  • Session creation fails: Check the browser symbol, whether that browser is installed where the session executes, and whether the driver is available and compatible.
  • Local run works but remote run fails: Check the remote endpoint, network reachability, and the capabilities or authentication required by the remote environment.
  • Only one browser fails: Compare its browser-specific options and setup with the relevant Watir guide, then verify those details against current versions.
  • Session starts but an element is missing: Confirm the page loaded as expected and that the selector and assertion describe the application’s actual behavior in that browser.
  • Driver-related error appears: Treat the driver as a separate component in the command path. Check its availability and compatibility rather than assuming the test code is the cause.

The right fix depends on the error and environment; no single cause explains every session failure. Selenium’s driver troubleshooting guidance explains the driver’s role in browser communication.

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

Or skip the browser setup

If you need a page screenshot rather than an interactive Watir test, ScreenshotNeo is a website screenshot API and MCP server. Its one-call API returns an image or PDF for a URL; it does not replace a browser automation suite or cross-browser behavior assertions.

cURL, saving the returned screenshot as WebP:

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

See the ScreenshotNeo API documentation for request options. Before capture it can accept cookie/consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with response headers indicating the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Sign up free for 1,000 screenshots a month, with no card.

Frequently Asked Questions

Can Watir run the same tests in several browsers?

Yes. Select a browser when creating each session and run the same behavior-focused scenarios against each configured target.

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

Does a screenshot API replace Watir cross-browser testing?

No. A screenshot API captures a page; Watir with WebDriver automates interactions and assertions in browser sessions.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.