Class: Selenium::WebDriver::ClientConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/common/client_config.rb

Overview

Configuration for HTTP clients.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(open_timeout: 60, read_timeout: 120, max_redirects: 20, proxy: nil, extra_headers: nil, user_agent: nil, server_url: nil) ⇒ ClientConfig

Returns a new instance of ClientConfig.

Parameters:

  • open_timeout (Numeric) (defaults to: 60)

    Seconds to wait for the connection to open.

  • read_timeout (Numeric) (defaults to: 120)

    Seconds to wait for a response.

  • max_redirects (Integer) (defaults to: 20)

    Maximum number of redirects to follow.

  • proxy (Proxy) (defaults to: nil)

    Proxy to use for the connection.

  • extra_headers (Hash) (defaults to: nil)

    Additional headers to send with each request.

  • user_agent (String) (defaults to: nil)

    Value to send as the User-Agent header.

  • server_url (String, URI) (defaults to: nil)

    URL of the server to connect to.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/selenium/webdriver/common/client_config.rb', line 51

def initialize(open_timeout: 60,
               read_timeout: 120,
               max_redirects: 20,
               proxy: nil,
               extra_headers: nil,
               user_agent: nil,
               server_url: nil)
  @open_timeout = open_timeout
  @read_timeout = read_timeout
  @max_redirects = max_redirects
  @proxy = proxy || proxy_from_environment
  @extra_headers = extra_headers
  @user_agent = user_agent
  self.server_url = server_url
end

Class Attribute Details

.default_extra_headersObject

Returns the value of attribute default_extra_headers.



30
31
32
# File 'lib/selenium/webdriver/common/client_config.rb', line 30

def default_extra_headers
  @default_extra_headers
end

.default_user_agentObject



33
34
35
# File 'lib/selenium/webdriver/common/client_config.rb', line 33

def default_user_agent
  @default_user_agent ||= "selenium/#{WebDriver::VERSION} (ruby #{Platform.os})"
end

Instance Attribute Details

#extra_headersObject



71
72
73
# File 'lib/selenium/webdriver/common/client_config.rb', line 71

def extra_headers
  @extra_headers || self.class.default_extra_headers
end

#max_redirectsObject

Returns the value of attribute max_redirects.



38
39
40
# File 'lib/selenium/webdriver/common/client_config.rb', line 38

def max_redirects
  @max_redirects
end

#open_timeoutObject

Returns the value of attribute open_timeout.



38
39
40
# File 'lib/selenium/webdriver/common/client_config.rb', line 38

def open_timeout
  @open_timeout
end

#proxyObject

Returns the value of attribute proxy.



38
39
40
# File 'lib/selenium/webdriver/common/client_config.rb', line 38

def proxy
  @proxy
end

#read_timeoutObject

Returns the value of attribute read_timeout.



38
39
40
# File 'lib/selenium/webdriver/common/client_config.rb', line 38

def read_timeout
  @read_timeout
end

#server_urlObject

Returns the value of attribute server_url.



40
41
42
# File 'lib/selenium/webdriver/common/client_config.rb', line 40

def server_url
  @server_url
end

#user_agentObject



67
68
69
# File 'lib/selenium/webdriver/common/client_config.rb', line 67

def user_agent
  @user_agent || self.class.default_user_agent
end