From 7a2fe91c272aac3c667f4ebfd7af586a1c6e88ce Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 24 Feb 2013 00:33:30 +0100 Subject: [PATCH] Small improvements/cleanup. --- test/browser_test_helper.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 14f381c55..3ad8c68fe 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -14,27 +14,36 @@ class TestCase < Test::Unit::TestCase @browsers = [] end if !ENV['REMOTE_URL'] - browser = Selenium::WebDriver.for :firefox + if !ENV['BROWSER'] + ENV['BROWSER'] = 'firefox' + end + browser = Selenium::WebDriver.for( ENV['BROWSER'].to_sym ) @browsers.push browser return browser end -# return Watir::Browser.new if !ENV['REMOTE_URL'] caps = Selenium::WebDriver::Remote::Capabilities.send( ENV['BROWSER'] ) caps.platform = ENV['BROWSER_OS'] || 'Windows 2008' caps.version = ENV['BROWSER_VERSION'] || '8' - Selenium::WebDriver.for( + browser = Selenium::WebDriver.for( :remote, :url => ENV['REMOTE_URL'], :desired_capabilities => caps, ) - + @browsers.push browser + return browser end def teardown return if !@browsers + + # only shut down browser type once + # otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)" + shutdown = {} @browsers.each{ |browser| - browser.close + next if shutdown[ browser.browser ] + shutdown[ browser.browser ] = true + browser.quit } end