Sha256: c49c1220e9ff70a8cbbf64d4a980538b5ab94e5e267358f2318c69791a7f6410

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

module Taza
  class Browser
    
    # Create a browser instance depending on configuration.  Configuration should be read in via Taza::Settings.config.
    # 
    # Example:
    #     browser = Taza::Browser.create(Taza::Settings.config)
    #
    def self.create(params={})
      self.send("create_#{params[:driver]}".to_sym,params)
    end
    
    def self.browser_class(params)
      self.send("#{params[:driver]}_#{params[:browser]}".to_sym)
    end

    private    

    def self.create_watir(params)
      method = "watir_#{params[:browser]}"
      raise BrowserUnsupportedError unless self.respond_to?(method)
      watir = self.send(method).new
      watir
    end

    def self.create_selenium(params)
      require 'selenium'
      Selenium::SeleniumDriver.new(params[:server_ip],params[:server_port],'*' + params[:browser].to_s,params[:timeout])
    end

    def self.watir_firefox
      require 'firewatir'
      FireWatir::Firefox
    end

    def self.watir_safari
      require 'safariwatir'
      Watir::Safari
    end

    def self.watir_ie
      require 'watir'
      Watir::IE
    end
  end
  
  # We don't know how to create the browser you asked for
  class BrowserUnsupportedError < StandardError; end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
scudco-taza-0.8.3 lib/taza/browser.rb
scudco-taza-0.8.4 lib/taza/browser.rb
scudco-taza-0.8.5 lib/taza/browser.rb
scudco-taza-0.8.6 lib/taza/browser.rb
taza-0.8.5 lib/taza/browser.rb
taza-0.8.4 lib/taza/browser.rb
taza-0.8.3 lib/taza/browser.rb
taza-0.8.6 lib/taza/browser.rb