lib/rdee/browser_factory.rb in RDee-0.1 vs lib/rdee/browser_factory.rb in RDee-0.2
- old
+ new
@@ -1,13 +1,18 @@
require_relative 'target_parser'
+
+
module RDee
+ class ConnectionError < StandardError
+ end
+
class BrowserFactory
include TargetParser
attr_accessor :url, :persistent_http, :chrome_options, :firefox_options,
- :ie_options, :safari_options, :opera_options
+ :ie_options, :safari_options
def watir_browser(target, options)
platform, options = platform_and_options(target, options)
watir_browser_for(platform, options)
end
@@ -18,22 +23,32 @@
end
private
def watir_browser_for(platform, options)
- if options.empty?
- Watir::Browser.new platform
- else
- Watir::Browser.new platform, options
+ begin
+ if options.empty?
+ Watir::Browser.new platform
+ else
+ Watir::Browser.new platform, options
+ end
+ rescue Exception => e
+ $stderr.puts e
+ raise RDee::ConnectionError, e
end
end
def selenium_browser_for(platform, options)
- if options.empty?
- Selenium::WebDriver.for platform
- else
- Selenium::WebDriver.for platform, options
- end
+ begin
+ if options.empty?
+ Selenium::WebDriver.for platform
+ else
+ Selenium::WebDriver.for platform, options
+ end
+ rescue Exception => e
+ $stderr.puts e
+ raise RDee::ConnectionError, e
+ end
end
def platform_and_options(target, options)
target = ENV['RDEE_BROWSER'].to_sym if ENV['RDEE_BROWSER']
platform, version, host = parse(target)