Permalink
Browse files

Delay loading selenium until driver in instantiated

Another attempt at fixing #1018
  • Loading branch information...
1 parent a95518e commit 4772f509f88ba5f2dcd5841846d0347423e8c9ed @jnicklas jnicklas committed Mar 18, 2013
Showing with 10 additions and 11 deletions.
  1. +10 −11 lib/capybara/selenium/driver.rb
@@ -1,14 +1,3 @@
-begin
- require 'selenium-webdriver'
-rescue LoadError => e
- if e.message =~ /selenium-webdriver/
- raise LoadError, "Capybara's selenium driver is unable to load `selenium-webdriver`, please install the gem and add `gem 'selenium-webdriver'` to your Gemfile if you are using bundler."
- else
- raise e
- end
-end
-
-
class Capybara::Selenium::Driver < Capybara::Driver::Base
DEFAULT_OPTIONS = {
:browser => :firefox
@@ -33,6 +22,16 @@ def browser
end
def initialize(app, options={})
+ begin
+ require 'selenium-webdriver'
+ rescue LoadError => e
+ if e.message =~ /selenium-webdriver/
+ raise LoadError, "Capybara's selenium driver is unable to load `selenium-webdriver`, please install the gem and add `gem 'selenium-webdriver'` to your Gemfile if you are using bundler."
+ else
+ raise e
+ end
+ end
+
@app = app
@browser = nil
@exit_status = nil

0 comments on commit 4772f50

Please sign in to comment.