Class: Selenium::Rake::ServerTask

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/rake/server_task.rb

Overview

Defines rake tasks for starting, stopping and restarting the Selenium server.

Usage:

Selenium::Rake::ServerTask.new do |t|
  t.jar = "/path/to/selenium-server-standalone.jar"
  t.port = 4444
  t.opts = %w[-some options]
end

Tasks defined:

rake selenium:server:start rake selenium:server:stop rake selenium:server:restart

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix = "selenium:server") {|_self| ... } ⇒ ServerTask

Returns a new instance of ServerTask.

Yields:

  • (_self)

Yield Parameters:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/selenium/rake/server_task.rb', line 78

def initialize(prefix = "selenium:server")
  @jar = nil
  @prefix = prefix
  @port = 4444
  @timeout = 30
  @background = true
  @log = true
  @opts = []

  yield self if block_given?

  unless @jar
    raise MissingJarFileError, "must provide path to the selenium server jar"
  end

  @server = Selenium::Server.new(@jar, :port       => @port,
                                       :timeout    => @timeout,
                                       :background => @background,
                                       :log        => @log )

  @server << @opts

  define_start_task
  define_stop_task
  define_restart_task
end

Instance Attribute Details

#backgroundObject Also known as: background?

Whether we should detach from the server process. Default: true



57
58
59
# File 'lib/selenium/rake/server_task.rb', line 57

def background
  @background
end

#jarObject

Path to the selenium server jar



35
36
37
# File 'lib/selenium/rake/server_task.rb', line 35

def jar
  @jar
end

#logObject

Configure logging. Pass a log file path or a boolean. Default: true

true - log to stdout/stderr false - no logging String - log to the specified file



69
70
71
# File 'lib/selenium/rake/server_task.rb', line 69

def log
  @log
end

#optsObject

Add additional options passed to the server jar.



75
76
77
# File 'lib/selenium/rake/server_task.rb', line 75

def opts
  @opts
end

#portObject

Port to use for the server. Default: 4444



43
44
45
# File 'lib/selenium/rake/server_task.rb', line 43

def port
  @port
end

#timeoutObject

Timeout in seconds for the server to start/stop. Default: 30



50
51
52
# File 'lib/selenium/rake/server_task.rb', line 50

def timeout
  @timeout
end