Sha256: 05401b1cb1eba51a800e8790c258fbf6fc825041601139958f4018677204efca

Contents?: true

Size: 1.57 KB

Versions: 29

Compression:

Stored size: 1.57 KB

Contents

require 'selenium-webdriver'

#Monkey Patch's - Use with care!
#Path to allow true custom capabilities
#e.g. job name for sauce labs
module Selenium
  module WebDriver
    module Remote
      class Capabilities
        def custom_capabilities(opts)
          @custom_capabilities = opts
        end

        #hopefuly this alias approach will mean we capture changes in the webdriver method
        alias_method :old_as_json, :as_json
        def as_json(opts = nil)
          hash = old_as_json
          if @custom_capabilities 
            @custom_capabilities.each do |key, value|
              hash[key] = value
            end
          end
          hash
        end
      end
    end

    class Options
      def delete_cookies_in_domain(domain)
        delete_all_cookies #proxy to this method as WebDriver only deletes
        #by domain
      end
    end
  end
end

#Workaround for http://code.google.com/p/selenium/issues/detail?id=4007
module Selenium
  module WebDriver
    module Remote
      module Http
        class Default
          def new_http_client
            if @proxy
              unless @proxy.respond_to?(:http) && url = @proxy.http
                raise Error::WebDriverError, "expected HTTP proxy, got #{@proxy.inspect}"
              end

              proxy = URI.parse(url)

              clazz = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password)
              clazz.new(server_url.host, server_url.port)
            else
              Net::HTTP.new server_url.host, server_url.port
            end
          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
frameworks-capybara-1.1.1 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-1.1.0 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-1.0.0 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.34 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.33 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.32 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.31 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.30 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.29 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.28 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.27 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.25 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.24 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.23 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.22 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.21 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.20 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.19 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.18 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.17 lib/monkey-patches/webdriver-patches.rb