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:



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
104
# File 'lib/selenium/rake/server_task.rb', line 79

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



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

def background
  @background
end

#jarObject

Path to the selenium server jar



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

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



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

def log
  @log
end

#optsObject

Add additional options passed to the server jar.



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

def opts
  @opts
end

#portObject

Port to use for the server. Default: 4444



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

def port
  @port
end

#timeoutObject

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



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

def timeout
  @timeout
end