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.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
- 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:
Rank #2
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.
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.
Rank #3
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.
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 minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallHandle 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.
Rank #4
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.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.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesBest Value
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.
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.
Quick 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.




