class Selenium::WebDriver::Proxy

Constants

TYPES

Attributes

auto_detect[R]
ftp[R]
http[R]
no_proxy[R]
pac[R]
socks[R]
socks_password[R]
socks_username[R]
ssl[R]
type[R]

Public Class Methods

json_create(data) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 127
def json_create(data)
  return if data['proxyType'] == 'UNSPECIFIED'

  proxy = new

  proxy.type           = data['proxyType'].downcase.to_sym if data.has_key? 'proxyType'
  proxy.ftp            = data['ftpProxy'] if data.has_key? 'ftpProxy'
  proxy.http           = data['httpProxy'] if data.has_key? 'httpProxy'
  proxy.no_proxy       = data['noProxy'] if data.has_key? 'noProxy'
  proxy.pac            = data['proxyAutoconfigUrl'] if data.has_key? 'proxyAutoconfigUrl'
  proxy.ssl            = data['sslProxy'] if data.has_key? 'sslProxy'
  proxy.auto_detect    = data['autodetect'] if data.has_key? 'autodetect'
  proxy.socks          = data['socksProxy'] if data.has_key? 'socksProxy'
  proxy.socks_username = data['socksUsername'] if data.has_key? 'socksUsername'
  proxy.socks_password = data['socksPassword'] if data.has_key? 'socksPassword'

  proxy
end
new(opts = {}) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 23
def initialize(opts = {})
  opts = opts.dup

  self.type           = opts.delete(:type) if opts.has_key? :type
  self.ftp            = opts.delete(:ftp) if opts.has_key? :ftp
  self.http           = opts.delete(:http) if opts.has_key? :http
  self.no_proxy       = opts.delete(:no_proxy) if opts.has_key? :no_proxy
  self.ssl            = opts.delete(:ssl) if opts.has_key? :ssl
  self.pac            = opts.delete(:pac) if opts.has_key? :pac
  self.auto_detect    = opts.delete(:auto_detect) if opts.has_key? :auto_detect
  self.socks          = opts.delete(:socks) if opts.has_key? :socks
  self.socks_username = opts.delete(:socks_username) if opts.has_key? :socks_username
  self.socks_password = opts.delete(:socks_password) if opts.has_key? :socks_password

  unless opts.empty?
    raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
  end
end

Public Instance Methods

==(other) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 42
def ==(other)
  other.kind_of?(self.class) && as_json == other.as_json
end
Also aliased as: eql?
as_json(opts = nil) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 104
def as_json(opts = nil)
  json_result = {
    "proxyType" => TYPES[type]
  }

  json_result["ftpProxy"]           = ftp if ftp
  json_result["httpProxy"]          = http if http
  json_result["noProxy"]            = no_proxy if no_proxy
  json_result["proxyAutoconfigUrl"] = pac if pac
  json_result["sslProxy"]           = ssl if ssl
  json_result["autodetect"]         = auto_detect if auto_detect
  json_result["socksProxy"]         = socks if socks
  json_result["socksUsername"]      = socks_username if socks_username
  json_result["socksPassword"]      = socks_password if socks_password

  json_result if json_result.length > 1
end
auto_detect=(bool) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 72
def auto_detect=(bool)
  self.type = :auto_detect
  @auto_detect = bool
end
eql?(other)
Alias for: ==
ftp=(value) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 47
def ftp=(value)
  self.type = :manual
  @ftp = value
end
http=(value) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 52
def http=(value)
  self.type = :manual
  @http = value
end
no_proxy=(value) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 57
def no_proxy=(value)
  self.type = :manual
  @no_proxy = value
end
pac=(url) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 67
def pac=(url)
  self.type = :pac
  @pac = url
end
socks=(value) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 77
def socks=(value)
  self.type = :manual
  @socks = value
end
socks_password=(value) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 87
def socks_password=(value)
  self.type = :manual
  @socks_password = value
end
socks_username=(value) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 82
def socks_username=(value)
  self.type = :manual
  @socks_username = value
end
ssl=(value) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 62
def ssl=(value)
  self.type = :manual
  @ssl = value
end
to_json(*args) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 122
def to_json(*args)
  WebDriver.json_dump as_json
end
type=(type) click to toggle source
# File lib/selenium/webdriver/common/proxy.rb, line 92
def type=(type)
  unless TYPES.has_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