Class: Selenium::Rake::RemoteControlStartTask

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

Overview

Rake tasks to start a Remote Control server.

require ‘selenium/rake/tasks’

Selenium::Rake::RemoteControlStartTask.new do |rc|

rc.port = 4444
rc.timeout_in_seconds = 3 * 60
rc.background = true
rc.wait_until_up_and_running = true
rc.jar_file = "/path/to/where/selenium-rc-standalone-jar-is-installed"
rc.additional_args << "-singleWindow"

end

If you do not explicitly specify the path to selenium remote control jar it will be “auto-discovered” in ‘vendor` directory using the following path : `vendor/selenium-remote-control/selenium-server*-standalone.jar`

To leverage the latest selenium-client capabilities, you may need to download a recent nightly build of a standalone packaging of Selenium Remote Control. You will find the nightly build at nexus.openqa.org/content/repositories/snapshots/org/seleniumhq/selenium/server/selenium-server/

Constant Summary collapse

JAR_FILE_PATTERN =
"vendor/selenium-remote-control/selenium-server-*.jar"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :'selenium:rc:start') {|_self| ... } ⇒ RemoteControlStartTask

Returns a new instance of RemoteControlStartTask.

Yields:

  • (_self)

Yield Parameters:



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/selenium/rake/remote_control_start_task.rb', line 33

def initialize(name = :'selenium:rc:start')
  @name = name
  @host = "localhost"
  @port = 4444
  @timeout_in_seconds = 5
  project_specific_jar = Dir[JAR_FILE_PATTERN].first
  @jar_file = project_specific_jar
  @additional_args = []
  @background = false
  @wait_until_up_and_running = false
  yield self if block_given?
  define
end

Instance Attribute Details

#additional_argsObject

Returns the value of attribute additional_args.



26
27
28
# File 'lib/selenium/rake/remote_control_start_task.rb', line 26

def additional_args
  @additional_args
end

#backgroundObject

Returns the value of attribute background.



26
27
28
# File 'lib/selenium/rake/remote_control_start_task.rb', line 26

def background
  @background
end

#hostObject

Returns the value of attribute host.



26
27
28
# File 'lib/selenium/rake/remote_control_start_task.rb', line 26

def host
  @host
end

#jar_fileObject

Returns the value of attribute jar_file.



29
30
31
# File 'lib/selenium/rake/remote_control_start_task.rb', line 29

def jar_file
  @jar_file
end

#log_toObject

Returns the value of attribute log_to.



26
27
28
# File 'lib/selenium/rake/remote_control_start_task.rb', line 26

def log_to
  @log_to
end

#portObject

Returns the value of attribute port.



26
27
28
# File 'lib/selenium/rake/remote_control_start_task.rb', line 26

def port
  @port
end

#timeout_in_secondsObject

Returns the value of attribute timeout_in_seconds.



26
27
28
# File 'lib/selenium/rake/remote_control_start_task.rb', line 26

def timeout_in_seconds
  @timeout_in_seconds
end

#wait_until_up_and_runningObject

Returns the value of attribute wait_until_up_and_running.



26
27
28
# File 'lib/selenium/rake/remote_control_start_task.rb', line 26

def wait_until_up_and_running
  @wait_until_up_and_running
end

Instance Method Details

#defineObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/selenium/rake/remote_control_start_task.rb', line 51

def define
  desc "Launch Selenium Remote Control"
  task @name do
    puts "Starting Selenium Remote Control at 0.0.0.0:#{@port}..."
    raise "Could not find jar file '#{@jar_file}'. Expected it under #{JAR_FILE_PATTERN}" unless @jar_file && File.exists?(@jar_file)
    remote_control = Selenium::RemoteControl::RemoteControl.new("0.0.0.0", @port, :timeout => @timeout_in_seconds)
    remote_control.jar_file = @jar_file
    remote_control.additional_args = @additional_args
    remote_control.log_to = @log_to
    remote_control.start :background => @background
    if @background && @wait_until_up_and_running
      puts "Waiting for Remote Control to be up and running..."
      TCPSocket.wait_for_service :host => @host, :port => @port
    end
    puts "Selenium Remote Control at 0.0.0.0:#{@port} ready"
  end
end