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-0.3.0.rc5 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.3.0.rc4 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.3.0.rc3 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.3.0.rc2 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.16 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.15 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.14 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.13 lib/monkey-patches/webdriver-patches.rb
frameworks-capybara-0.2.12 lib/monkey-patches/webdriver-patches.rb