Class: SGrid::RemoteControl

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium-grid/lib/ruby/s_grid/remote_control.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RemoteControl

Returns a new instance of RemoteControl.



5
6
7
8
9
10
# File 'lib/selenium-grid/lib/ruby/s_grid/remote_control.rb', line 5

def initialize(options={})
  @host = options[:host] || "localhost"
  @port = (options[:port] || "4444").to_i
  @hub_url = options[:hub_url] || "http://localhost:4444"
  @shutdown_command = options[:shutdown_command] || "shutDownSeleniumServer"
end

Instance Method Details

#rc_args(options) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/selenium-grid/lib/ruby/s_grid/remote_control.rb', line 28

def rc_args(options)
  args = []
  args << "-host" << @host
  args << "-port" << @port
  args << "-hubUrl" << @hub_url
  args << %Q{-env "#{options[:environment] || ENV['ENVIRONMENT'] || '*firefox'}"} 
  args << (options[:selenium_args] || ENV['SELENIUM_ARGS'] || "")
  args
end

#shutdownObject



23
24
25
26
# File 'lib/selenium-grid/lib/ruby/s_grid/remote_control.rb', line 23

def shutdown
  http = Net::HTTP.new(@host, @port)
  http.post('/selenium-server/driver/', "cmd=#{@shutdown_command}")
end

#start(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/selenium-grid/lib/ruby/s_grid/remote_control.rb', line 12

def start(options={})
    # Selenium Server must be first in classpath
    root = File.expand_path(File.dirname(__FILE__) + "/../../..")
    classpath = Java::Classpath.new(root)
    classpath = classpath << "." << "vendor/selenium-server-*.jar" 
    classpath = classpath << "lib/selenium-grid-remote-control-standalone-*.jar"
    Java::VM.new.run "com.thoughtworks.selenium.grid.remotecontrol.SelfRegisteringRemoteControlLauncher",
                     options.merge(:classpath => classpath.definition, 
                                   :args => rc_args(options))
end