Class: SeleniumGrid::Remote
- Inherits:
-
Object
- Object
- SeleniumGrid::Remote
- Includes:
- Singleton, Utils
- 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 => ENV['LOG'] || overrides[:log] || File.join(".", "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
- #arguments(overrides = {}) ⇒ Object
- #list ⇒ Object
- #ps ⇒ Object
- #running?(port = ENV['PORT'] || DEFAULT_PORT) ⇒ Boolean
- #stop(overrides = {}) ⇒ Object
Instance Method Details
#arguments(overrides = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/selenium-grid/remote.rb', line 53 def arguments(overrides = {}) = { :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) [:env] = "'#{[:env].gsub(/["']/, '')}'" end |
#list ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/selenium-grid/remote.rb', line 36 def list return {} unless Netstat.instance.running?(Hub::HUB_PORT) remotes = ps.split(/\n|\r/) return {} if remotes.empty? remotes.inject({}) do |remotes, remote| parts = remote.split(/\s/) port = parts[parts.index('-port') + 1] browser = parts[parts.index('-env') + 1] remotes.merge({ port => browser }) end end |
#ps ⇒ Object
65 66 67 |
# File 'lib/selenium-grid/remote.rb', line 65 def ps %x{ ps auwx | grep com.thoughtworks.selenium.grid.remotecontrol.SelfRegisteringRemoteControlLauncher | sed '/sh -c java/d' | grep -v grep } end |
#running?(port = ENV['PORT'] || DEFAULT_PORT) ⇒ Boolean
49 50 51 |
# File 'lib/selenium-grid/remote.rb', line 49 def running?(port = ENV['PORT'] || DEFAULT_PORT) Netstat.instance.running?(port) end |
#stop(overrides = {}) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/selenium-grid/remote.rb', line 28 def stop(overrides = {}) = { :port => ENV['PORT'] || DEFAULT_PORT }.merge(overrides) Lsof.kill([:port].to_i) end |