Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Commit

Permalink
Browser class now knows which implementations support which browsers.
Browse files Browse the repository at this point in the history
  • Loading branch information
bret committed Oct 28, 2008
1 parent cbcd66b commit 48eb3e6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion firewatir/lib/firewatir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1176,4 +1176,4 @@ def js_eval(str)
end

require 'watir/browser'
Watir::Browser.module_eval "@@klass = FireWatir::Firefox"
Watir.default_browser ||= 'firefox'
19 changes: 16 additions & 3 deletions watir-common/lib/watir/browser.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
# watir/browser
require 'watir/options'
module FireWatir
autoload :Firefox, 'firewatir'
end

module Watir
autoload :IE, 'watir'

module Browser
@@klass = nil
@@browser_classes = {
'ie' => 'Watir::IE',
'firefox' => 'FireWatir::Firefox'
}
class << self
def new *args
@@klass.new *args
klass.new *args
end
def start *args
@@klass.start *args
klass.start *args
end
def klass
key = Watir.options[:browser]
eval @@browser_classes[key] # this triggers the autoload
end
end
end

end
3 changes: 0 additions & 3 deletions watir-common/unittests/setup/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
case Watir.options[:browser]
when 'ie'
at_exit {Watir::IE.quit}

$LOAD_PATH.unshift File.expand_path($watir_dev_lib)
require 'watir'

speed = Watir.options[:speed].to_sym
Watir::IE.speed = speed
$browser = Watir::Browser.new
$browser.speed = speed
when 'firefox'
$LOAD_PATH.unshift File.expand_path($firewatir_dev_lib)
require 'firewatir'
$browser = Watir::Browser.new
end

Expand Down
2 changes: 1 addition & 1 deletion watir/lib/watir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
require 'watir/collections'

require 'watir/browser'
Watir::Browser.module_eval "@@klass = Watir::IE"
Watir.default_browser ||= 'ie'

module Watir
include Watir::Exception
Expand Down

0 comments on commit 48eb3e6

Please sign in to comment.