Class: SeleniumRC::Server
- Inherits:
-
Object
- Object
- SeleniumRC::Server
- Defined in:
- lib/selenium_rc/server.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
Instance Method Summary collapse
- #boot ⇒ Object
- #fail ⇒ Object
-
#initialize(host, port = nil, options = {}) ⇒ Server
constructor
A new instance of Server.
- #ready? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(host, port = nil, options = {}) ⇒ Server
Returns a new instance of Server.
19 20 21 22 23 24 |
# File 'lib/selenium_rc/server.rb', line 19 def initialize(host, port = nil, = {}) @host = host @port = port || 4444 @args = [:args] || [] @timeout = [:timeout] || 60 end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
6 7 8 |
# File 'lib/selenium_rc/server.rb', line 6 def args @args end |
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/selenium_rc/server.rb', line 4 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/selenium_rc/server.rb', line 5 def port @port end |
#timeout ⇒ Object
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/selenium_rc/server.rb', line 7 def timeout @timeout end |
Class Method Details
.boot(*args) ⇒ Object
10 11 12 |
# File 'lib/selenium_rc/server.rb', line 10 def boot(*args) new(*args).boot end |
.jar_path ⇒ Object
14 15 16 |
# File 'lib/selenium_rc/server.rb', line 14 def jar_path File.("#{File.dirname(__FILE__)}/../../vendor/selenium-server.jar") end |
Instance Method Details
#boot ⇒ Object
26 27 28 29 30 31 |
# File 'lib/selenium_rc/server.rb', line 26 def boot start wait at_exit { stop } self end |
#fail ⇒ Object
57 58 59 60 61 62 |
# File 'lib/selenium_rc/server.rb', line 57 def fail $stderr.puts $stderr.puts $stderr.puts "==> Failed to boot the Selenium Server... exiting!" exit end |
#ready? ⇒ Boolean
68 69 70 71 72 73 74 |
# File 'lib/selenium_rc/server.rb', line 68 def ready? begin selenium_command('testComplete') == 'OK' rescue Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EPIPE, Net::HTTPBadResponse false end end |
#start ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/selenium_rc/server.rb', line 33 def start command = "java -jar \"#{self.class.jar_path}\"" command << " -port #{port}" command << " #{args.join(' ')}" unless args.empty? begin fork do system(command) at_exit { exit!(0) } end rescue NotImplementedError Thread.start do system(command) end end end |
#stop ⇒ Object
64 65 66 |
# File 'lib/selenium_rc/server.rb', line 64 def stop selenium_command('shutDownSeleniumServer') end |
#wait ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/selenium_rc/server.rb', line 49 def wait $stderr.print "==> Waiting for Selenium Server on port #{port}... " wait_for_service_with_timeout $stderr.print "Ready!\n" rescue ServerNotStarted fail end |