Sha256: ba5e73a876f4f6b2543794e1f99d504194e7164ee99b10a27fe6d90121595b77

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

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

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

        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
        browser = target.gsub('local_', '').to_sym
        Watir::Browser.new browser, :http_client => client
      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

6 entries across 6 versions & 1 rubygems

Version Path
druid-ts-1.2.6 features/support/persistent_browser.rb
druid-ts-1.2.5 features/support/persistent_browser.rb
druid-ts-1.2.4 features/support/persistent_browser.rb
druid-ts-1.2.3 features/support/persistent_browser.rb
druid-ts-1.2.2 features/support/persistent_browser.rb
druid-ts-1.2.1 features/support/persistent_browser.rb