Method: Selenium::Server#initialize

Defined in:
lib/selenium/server.rb

#initialize(jar, opts = {}) ⇒ Server

Returns a new instance of Server.

Parameters:

  • jar (String)

    Path to the server jar.

  • opts (Hash) (defaults to: {})

    the options to create the server process with

Options Hash (opts):

  • :port (Integer)

    Port the server should listen on (default: 4444).

  • :timeout (Integer)

    Seconds to wait for server launch/shutdown (default: 30)

  • :background (true, false)

    Run the server in the background (default: false)

  • :log (true, false, String)

    Either a path to a log file, or true to pass server log to stdout.

Raises:

  • (Errno::ENOENT)

    if the jar file does not exist



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/selenium/server.rb', line 182

def initialize(jar, opts = {})
  raise Errno::ENOENT, jar unless File.exist?(jar)

  @jar = jar
  @host = '127.0.0.1'
  @role = opts.fetch(:role, 'standalone')
  @port = opts.fetch(:port, 4444)
  @timeout = opts.fetch(:timeout, 30)
  @background = opts.fetch(:background, false)
  @additional_args = opts.fetch(:args, [])
  @log = opts[:log]
  if opts[:log_level]
    @log ||= true
    @additional_args << '--log-level'
    @additional_args << opts[:log_level].to_s
  end

  @log_file = nil
end