SeleniumHQ/selenium · error · ArgumentError

unknown driver: #{browser.inspect}

Error message

unknown driver: #{browser.inspect}

What it means

Selenium::WebDriver.for(browser) dispatches to the matching driver constructor for a fixed set of browser symbols. An unrecognized symbol falls through the case and raises ArgumentError listing the offending value. Supported symbols include :chrome, :internet_explorer/:ie, :safari, :firefox/:ff, :edge/:microsoftedge/:msedge, and :remote.

Source

Thrown at rb/lib/selenium/webdriver/common/driver.rb:59

        # @return [Driver]
        #

        def for(browser, opts = {})
          case browser
          when :chrome, :chrome_headless_shell
            Chrome::Driver.new(**opts)
          when :internet_explorer, :ie
            IE::Driver.new(**opts)
          when :safari
            Safari::Driver.new(**opts)
          when :firefox, :ff
            Firefox::Driver.new(**opts)
          when :edge, :microsoftedge, :msedge
            Edge::Driver.new(**opts)
          when :remote
            Remote::Driver.new(**opts)
          else
            raise ArgumentError, "unknown driver: #{browser.inspect}"
          end
        end
      end

      #
      # A new Driver instance with the given bridge.
      # End users should use Selenium::WebDriver.for instead of using this directly.
      #
      # @api private
      #

      def initialize(bridge: nil, listener: nil, **)
        @devtools = nil
        bridge ||= create_bridge(**)
        @bridge = listener ? Support::EventFiringBridge.new(bridge, listener) : bridge
        add_extensions(@bridge.browser)
      end

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Use one of the supported symbols: :chrome, :firefox, :edge, :safari, :ie/:internet_explorer, or :remote.
  2. Pass a Symbol, not a String: Selenium::WebDriver.for(:chrome).
  3. For Chromium-based unsupported browsers, use Selenium::WebDriver.for(:chrome) with Options#binary, or :remote pointing at a compatible endpoint.
  4. Check the current supported list in the Selenium Ruby docs for your version.

Example fix

// before
Selenium::WebDriver.for('chrome')
Selenium::WebDriver.for(:brave)
// after
Selenium::WebDriver.for(:chrome)
options = Selenium::WebDriver::Chrome::Options.new(binary: '/usr/bin/brave')
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = %i[chrome firefox edge safari internet_explorer ie remote ff microsoftedge msedge].freeze

raise ArgumentError, "unsupported browser #{browser.inspect}" unless SUPPORTED.include?(browser.to_sym)
Selenium::WebDriver.for(browser.to_sym)

Type guard

def supported_browser?(b)
  %i[chrome firefox edge safari internet_explorer ie remote ff microsoftedge msedge].include?(b.to_sym)
end

Try / catch

begin
  Selenium::WebDriver.for(browser)
rescue ArgumentError => e
  raise unless e.message =~ /unknown driver/
  Selenium::WebDriver.for(browser.to_sym)
end

Prevention

When it happens

Trigger: Calling Selenium::WebDriver.for(:brave), Selenium::WebDriver.for('chrome') (String instead of Symbol), or any symbol outside the supported set.

Common situations: Typo in the browser name, passing a String where a Symbol is expected, expecting an unsupported browser (Brave/Opera/Vivaldi) to work directly instead of via :remote with options, using a stale symbol removed in a newer version.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/19ca99b77092d4c4. Report an issue: GitHub.