SeleniumHQ/selenium · error · TypeError
expected #{Proxy.name}, got #{proxy.inspect}:#{proxy.class}
Error message
expected #{Proxy.name}, got #{proxy.inspect}:#{proxy.class} What it means
Raised by Firefox::Profile#proxy= (TypeError) when the argument is not an instance of Selenium::WebDriver::Proxy. The setter then switches on proxy.type to configure the corresponding network.proxy.* preferences.
Source
Thrown at rb/lib/selenium/webdriver/firefox/profile.rb:138
def load_no_focus_lib=(value)
WebDriver.logger.deprecate('Firefox::Profile#load_no_focus_lib=', id: :firefox_profile)
@load_no_focus_lib = value
end
def log_file=(file)
@log_file = file
self[WEBDRIVER_PREFS[:log_file]] = file
end
def add_extension(path, name = extension_name_for(path))
WebDriver.logger.deprecate('Firefox::Profile#add_extension', 'Driver#install_addon',
id: :firefox_profile)
@extensions[name] = Extension.new(path)
end
def proxy=(proxy)
raise TypeError, "expected #{Proxy.name}, got #{proxy.inspect}:#{proxy.class}" unless proxy.is_a? Proxy
case proxy.type
when :manual
self['network.proxy.type'] = 1
set_manual_proxy_preference 'http', proxy.http
set_manual_proxy_preference 'ssl', proxy.ssl
set_manual_proxy_preference 'socks', proxy.socks
self['network.proxy.no_proxies_on'] = proxy.no_proxy || ''
when :pac
self['network.proxy.type'] = 2
self['network.proxy.autoconfig_url'] = proxy.pac
when :auto_detect
self['network.proxy.type'] = 4
else
raise ArgumentError, "unsupported proxy type #{proxy.type}"
endView on GitHub (pinned to aa36b38e69)
Solutions
- Construct a Selenium::WebDriver::Proxy.new(type: :manual, http: 'host:8080') and assign that.
- Prefer setting the proxy on Capabilities (options.proxy = Proxy.new(...)) rather than on the Firefox profile directly.
- If you only have a hash, convert it with Proxy.new(hash).
Example fix
// before
profile.proxy = {type: :manual, http: 'proxy.example.com:8080'}
// after
profile.proxy = Selenium::WebDriver::Proxy.new(
type: :manual, http: 'proxy.example.com:8080'
)
# or preferred: set on capabilities
options = Selenium::WebDriver::Firefox::Options.new
options.proxy = Selenium::WebDriver::Proxy.new(type: :manual, http: 'proxy.example.com:8080') Defensive patterns
Strategy: type-guard
Validate before calling
proxy = Selenium::WebDriver::Proxy.new(proxy_hash) unless proxy.is_a?(Selenium::WebDriver::Proxy) profile.proxy = proxy
Type guard
def selenium_proxy?(obj) obj.is_a?(Selenium::WebDriver::Proxy) end
Prevention
- Always build a Selenium::WebDriver::Proxy object before assigning it.
- Prefer setting proxy on Options/Capabilities rather than the Firefox profile.
- Convert proxy hashes with Proxy.new(hash) before assignment.
When it happens
Trigger: Assigning a hash of proxy settings (e.g. {type: :manual, http: 'host:8080'}) or a URI/string instead of a Proxy object to profile.proxy=.
Common situations: Building proxy config from a hash read out of Capabilities by mistake; passing the proxy at the wrong layer (profile vs Capabilities); confusing this with the Capabilities proxy= which accepts a hash.
Related errors
- expected one of #{VALID_PREFERENCE_TYPES.inspect}, got #{val
- unsupported proxy type #{proxy.type}
- Port needs to be an integer
- Port number must be in the range 1..65535
- Please pass in a Boolean to this call
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/35742e4dd5339017.
Report an issue: GitHub.