class Selenium::WebDriver::Proxy
def self.json_create(data)
def self.json_create(data) data['proxyType'] = data['proxyType'].downcase.to_sym return if data['proxyType'] == :unspecified proxy = new ALLOWED.each do |k, v| proxy.send(:"#{k}=", data[v]) if data.key?(v) end proxy end
def ==(other)
def ==(other) other.is_a?(self.class) && as_json == other.as_json end
def as_json(*)
def as_json(*) json_result = { 'proxyType' => TYPES[type].downcase, 'ftpProxy' => ftp, 'httpProxy' => http, 'noProxy' => no_proxy.is_a?(String) ? no_proxy.split(', ') : no_proxy, 'proxyAutoconfigUrl' => pac, 'sslProxy' => ssl, 'autodetect' => auto_detect, 'socksProxy' => socks, 'socksUsername' => socks_username, 'socksPassword' => socks_password, 'socksVersion' => socks_version }.compact json_result if json_result.length > 1 end
def auto_detect=(bool)
def auto_detect=(bool) self.type = :auto_detect @auto_detect = bool end
def ftp=(value)
def ftp=(value) self.type = :manual @ftp = value end
def http=(value)
def http=(value) self.type = :manual @http = value end
def initialize(opts = {})
def initialize(opts = {}) not_allowed = [] opts.each do |k, v| if ALLOWED.key?(k) send(:"#{k}=", v) else not_allowed << k end end return if not_allowed.empty? raise ArgumentError, "unknown option#{'s' if not_allowed.size != 1}: #{not_allowed.inspect}" end
def no_proxy=(value)
def no_proxy=(value) self.type = :manual @no_proxy = value end
def pac=(url)
def pac=(url) self.type = :pac @pac = url end
def socks=(value)
def socks=(value) self.type = :manual @socks = value end
def socks_password=(value)
def socks_password=(value) self.type = :manual @socks_password = value end
def socks_username=(value)
def socks_username=(value) self.type = :manual @socks_username = value end
def socks_version=(value)
def socks_version=(value) self.type = :manual @socks_version = value end
def ssl=(value)
def ssl=(value) self.type = :manual @ssl = value end
def to_json(*)
def to_json(*) JSON.generate as_json end
def type=(type)
def type=(type) unless TYPES.key? type raise ArgumentError, "invalid proxy type: #{type.inspect}, expected one of #{TYPES.keys.inspect}" end if defined?(@type) && type != @type raise ArgumentError, "incompatible proxy type #{type.inspect} (already set to #{@type.inspect})" end @type = type end