features/support/env.rb in dojo_widgets-0.1 vs features/support/env.rb in dojo_widgets-0.2
- old
+ new
@@ -5,12 +5,29 @@
require 'page-object'
require 'watir-webdriver'
World(PageObject::PageFactory)
+module PersistentBrowser
+
+ @@browser = false
+
+ def self.get_browser
+ unless @@browser
+ @@browser = Watir::Browser.new :firefox if ENV['DRIVER'] == 'WATIR'
+ @@browser = Selenium::WebDriver.for :firefox if ENV['DRIVER'] == 'SELENIUM'
+ end
+ @@browser
+ end
+
+ def self.quit
+ @@browser.quit
+ end
+end
+
Before do
- @browser = Watir::Browser.new :firefox
+ @browser = PersistentBrowser.get_browser
end
-After do
- @browser.close
+at_exit do
+ PersistentBrowser.quit
end