Skip to content

Commit

Permalink
Adding methods to start and stop the selenium server java process
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Nov 23, 2008
1 parent f6ce5bb commit e6cb40b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/webrat/selenium.rb
Expand Up @@ -2,4 +2,30 @@
require "selenium/client"
require "webrat/selenium/selenium_session"

Webrat.configuration.mode = :selenium
Webrat.configuration.mode = :selenium

module Webrat

def self.with_selenium_server
start_selenium_server
yield
stop_selenium_server
end

def self.start_selenium_server
remote_control = Selenium::RemoteControl::RemoteControl.new("0.0.0.0", 4444, 5)
remote_control.jar_file = File.expand_path(__FILE__ + "../../../../vendor/selenium-server.jar")
remote_control.start :background => true
puts "Waiting for Remote Control to be up and running..."
TCPSocket.wait_for_service :host => "0.0.0.0", :port => 4444
puts "Selenium Remote Control at 0.0.0.0:4444 ready"
end

def self.stop_selenium_server
puts "Stopping Selenium Remote Control running at 0.0.0.0:4444..."
remote_control = Selenium::RemoteControl::RemoteControl.new("0.0.0.0", 4444, 5)
remote_control.stop
puts "Stopped Selenium Remote Control running at 0.0.0.0:4444"
end

end

0 comments on commit e6cb40b

Please sign in to comment.