Sha256: 32abfb804914264d35c8931f7c265fcee93b5f75be6aad953a4e5f994102b277

Contents?: true

Size: 778 Bytes

Versions: 2

Compression:

Stored size: 778 Bytes

Contents

module WatirWebdriverRails
  class << self
    attr_accessor :browser,:browser_initialized
    
    def initialize_browser
      
      return if @browser_initialized == true
      
      @browser = Watir::Browser.new(WatirWebdriverRails.driver)
      
      @browser.class_eval do
         alias_method :old_goto,:goto
         
         def goto(*args)
           
           if !args[0].match(/^https?:/)
              args[0] = "http://#{WatirWebdriverRails.host}:#{WatirWebdriverRails.port}#{args[0]}"
           end
           
           old_goto(*args)      
         end
      end
      
      @browser_initialized = true
    end
    
    def close_browser
      @browser.close if @browser_initialized == true
      @browser_initialized = false
    end
     
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-webdriver-rails-0.0.8 lib/watir-webdriver-rails/browser.rb
watir-webdriver-rails-0.0.7 lib/watir-webdriver-rails/browser.rb