Class: SeleniumGrid::Remote

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/selenium-grid/remote.rb

Constant Summary collapse

DEFAULT_BROWSER =
"*chrome"
DEFAULT_PORT =
5555
DEFAULT_HOST =
"localhost"
DEFAULT_HUB_URL =
"http://#{DEFAULT_HOST}:#{Hub::HUB_PORT}",
  
def start(overrides = {})
  classpath = Java::Classpath.new(File.join(File.dirname(__FILE__), %w(.. ..)))
  classpath =  classpath << "." << "lib/openqa/selenium-server-*.jar" << "lib/openqa/selenium-grid-remote-control-standalone-*.jar"
  args = arguments(overrides.reject { |key, value| key == :background })
  
  options = {
   :classpath => classpath.definition,
   :log => File.join(File.dirname(__FILE__), "..", "..", "log", "rc-#{args[:port]}.log"),
   :arguments => args,
   :background => overrides[:background] || ENV['BACKGROUND'] || false,
  }

  Java::VM.new.run "com.thoughtworks.selenium.grid.remotecontrol.SelfRegisteringRemoteControlLauncher", options
end

Instance Method Summary collapse

Instance Method Details

#arguments(overrides = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/selenium-grid/remote.rb', line 34

def arguments(overrides = {})
  options = {
    :host => ENV['HOST'] || DEFAULT_HOST,
    :port => ENV['PORT'] || DEFAULT_PORT,
    :hub_url => ENV['HUB_URL'] || DEFAULT_HUB_URL,
    :env => ENV['ENV'] || DEFAULT_BROWSER,
    :selenium_args => ENV['SELENIUM_ARGS'] || ""
  }.merge(overrides)
  options[:env] = "'#{options[:env].gsub(/["']/, '')}'"
  options
end

#stop(overrides = {}) ⇒ Object



27
28
29
30
31
32
# File 'lib/selenium-grid/remote.rb', line 27

def stop(overrides = {})
  options = {
    :port => ENV['PORT'] || DEFAULT_PORT
  }.merge(overrides)
  Lsof.kill(options[:port].to_i)
end