Sha256: 42555e03391f805b430f1e84e024a89758a85774a1ad8d7dae2a34a5d795b8bb

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

require 'selenium/webdriver/remote/http/persistent'

module Druid
  module PersistantBrowser
    @@driver = false
    def self.get_browser
      if !@@driver
        target = ENV['BROWSER']
        target = 'firefox_local' unless target

        if is_remote?(target)
          require File.dirname(__FILE__) + "/targets/#{target}"
          extend Target
        end

        @@driver = watir_browser(target) if ENV['DRIVER'] == 'WATIR'
      end
      @@driver
    end

    def self.quit
      @@driver.quit
    end

    private

    def self.is_remote?(target)
      not target.include? 'local'
    end

    def self.watir_browser(target)
      if is_remote?(target)
        Watir::Browser.new(:remote,
                           :http_client => client,
                           :url => url,
                           :desired_capabilities => desired_capabilities )
      else
        Watir::Browser.new :firefox
      end
    end

    def self.client
      Selenium::WebDriver::Remote::Http::Persistent.new
    end

    def self.capabilities(browser, version, platform, name)
      caps = Selenium::WebDriver::Remote::Capabilities.send browser
      caps.version = version
      caps.platform = platform
      caps[:name] = name
      caps
    end

    def self.url
      "http://pageobject:18002ee8-963b-472e-9425-2baf0a2b6d95@ondemand.saucelabs.com:80/wd/hub"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
druid-ts-1.2.0 features/support/persistent_browser.rb
druid-ts-1.1.8 features/support/persistent_browser.rb
druid-ts-1.1.7 features/support/persistent_browser.rb