From e69623697ea16bb9fc68ed2031205e4089be2399 Mon Sep 17 00:00:00 2001 From: Niall Mullally Date: Tue, 3 Mar 2009 21:44:52 +0000 Subject: [PATCH] Added support for passing array of additional arguments to Selenium server startup. --- lib/webrat/core/configuration.rb | 8 +++++++- lib/webrat/selenium.rb | 3 ++- spec/private/core/configuration_spec.rb | 6 +++++- spec/private/selenium/selenium_spec.rb | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/webrat/core/configuration.rb b/lib/webrat/core/configuration.rb index bc9209e..3785993 100755 --- a/lib/webrat/core/configuration.rb +++ b/lib/webrat/core/configuration.rb @@ -58,6 +58,11 @@ module Webrat # loop? Defaults to 10 attr_accessor :infinite_redirect_limit + # Extra startup arguments to pass to the Selenium remote control + # e.g. to specify a particular firefox profile to use + # config.selenium_additional_startup_args = ["-firefoxProfileTemplate /path/to/profile"] + attr_accessor :selenium_additional_startup_args + def initialize # :nodoc: self.open_error_files = true self.parse_with_nokogiri = !Webrat.on_java? @@ -67,7 +72,8 @@ module Webrat self.application_framework = 'rails' self.selenium_server_port = 4444 self.infinite_redirect_limit = 10 - self.selenium_browser_key = '*firefox' + self.selenium_browser_key = '*firefox' + self.selenium_additional_startup_args = [] end def parse_with_nokogiri? #:nodoc: diff --git a/lib/webrat/selenium.rb b/lib/webrat/selenium.rb index 538f9d0..fabbabf 100644 --- a/lib/webrat/selenium.rb +++ b/lib/webrat/selenium.rb @@ -15,7 +15,8 @@ module Webrat def self.start_selenium_server #:nodoc: unless Webrat.configuration.selenium_server_address remote_control = ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0", Webrat.configuration.selenium_server_port, 5) - remote_control.jar_file = File.expand_path(__FILE__ + "../../../../vendor/selenium-server.jar") + remote_control.jar_file = File.expand_path(__FILE__ + "../../../../vendor/selenium-server.jar") + remote_control.additional_args = Webrat.configuration.selenium_additional_startup_args remote_control.start :background => true end TCPSocket.wait_for_service :host => (Webrat.configuration.selenium_server_address || "0.0.0.0"), :port => Webrat.configuration.selenium_server_port diff --git a/spec/private/core/configuration_spec.rb b/spec/private/core/configuration_spec.rb index abc5c86..2185ad7 100755 --- a/spec/private/core/configuration_spec.rb +++ b/spec/private/core/configuration_spec.rb @@ -98,7 +98,11 @@ describe Webrat::Configuration do it 'should default selenium browser key to *firefox' do @config.selenium_browser_key.should == '*firefox' - end + end + + it 'should default additional selenium remote control startup args to empty array' do + @config.selenium_additional_startup_args.should == [] + end end end diff --git a/spec/private/selenium/selenium_spec.rb b/spec/private/selenium/selenium_spec.rb index c4fe946..618d7f0 100644 --- a/spec/private/selenium/selenium_spec.rb +++ b/spec/private/selenium/selenium_spec.rb @@ -84,7 +84,8 @@ describe Webrat, "Selenium" do it "should start the local selenium server if the selenium_server_address is set" do remote_control = mock "selenium remote control" ::Selenium::RemoteControl::RemoteControl.should_receive(:new).with("0.0.0.0", Webrat.configuration.selenium_server_port, 5).and_return remote_control - remote_control.should_receive(:jar_file=).with(/selenium-server\.jar/) + remote_control.should_receive(:jar_file=).with(/selenium-server\.jar/) + remote_control.should_receive(:additional_args=).with(Webrat.configuration.selenium_additional_startup_args) remote_control.should_receive(:start).with(:background => true) TCPSocket.should_receive(:wait_for_service).with(:host => "0.0.0.0", :port => Webrat.configuration.selenium_server_port) Webrat.start_selenium_server -- 1.6.1.3