diff --git a/lib/webrat/core/configuration.rb b/lib/webrat/core/configuration.rb index b0dcfc1..70d5583 100755 --- a/lib/webrat/core/configuration.rb +++ b/lib/webrat/core/configuration.rb @@ -33,11 +33,40 @@ module Webrat # Which port should the selenium tests be run on? Defaults to 3001. attr_accessor :selenium_port + # The host of the selenium server - defaults to "0.0.0.0" + attr_accessor :selenium_server_host + + # The port to connect to on the selenium server - defaults to 4444 + attr_accessor :selenium_server_port + + # The browser to run on the selenium server - defaults to + # "*firefox" + attr_accessor :selenium_browser + + # The initial URL to pass to selenium - ie the URL of the app + # server as viewed from the selenium server - defaults to + # "http://0.0.0.0:3001/" + attr_accessor :selenium_initial_url + + # Whether to start the selenium server locally - defaults to true + attr_accessor :start_selenium_server + + # Whether to start an app server locally - defaults to true + attr_accessor :start_app_server + + def initialize # :nodoc: self.open_error_files = true self.parse_with_nokogiri = !Webrat.on_java? self.selenium_environment = :selenium self.selenium_port = 3001 + + self.selenium_server_host = "0.0.0.0" + self.selenium_server_port = 4444 + self.selenium_browser = "*firefox", + self.selenium_initial_url = "http://0.0.0.0:3001/" + self.start_selenium_server = true + self.start_app_server = true end def parse_with_nokogiri? #:nodoc: @@ -57,4 +86,4 @@ module Webrat end -end \ No newline at end of file +end diff --git a/lib/webrat/selenium/selenium_session.rb b/lib/webrat/selenium/selenium_session.rb index 460269e..2bf4e31 100644 --- a/lib/webrat/selenium/selenium_session.rb +++ b/lib/webrat/selenium/selenium_session.rb @@ -181,11 +181,14 @@ module Webrat def setup #:nodoc: silence_stream(STDOUT) do - Webrat.start_selenium_server - Webrat.start_app_server + Webrat.start_selenium_server if Webrat.configuration.start_selenium_server + Webrat.start_app_server if Webrat.configuration.start_app_server end - - $browser = ::Selenium::Client::Driver.new("localhost", 4444, "*firefox", "http://0.0.0.0:3001") + + $browser = ::Selenium::Client::Driver.new(Webrat.configuration.selenium_server_host, + Webrat.configuration.selenium_server_port, + Webrat.configuration.selenium_browser, + Webrat.configuration.selenium_initial_url) $browser.set_speed(0) $browser.start teardown_at_exit @@ -199,8 +202,8 @@ module Webrat at_exit do silence_stream(STDOUT) do $browser.stop - Webrat.stop_app_server - Webrat.stop_selenium_server + Webrat.stop_app_server if Webrat.configuration.start_app_server + Webrat.stop_selenium_server if Webrat.configuration.start_selenium_server end end end @@ -227,4 +230,4 @@ module Webrat end end end -end \ No newline at end of file +end