Sha256: 66af98a2f1641b8b38145ac93bde07ccee1d03ac581704072d0304f8a72262d1

Contents?: true

Size: 1.52 KB

Versions: 33

Compression:

Stored size: 1.52 KB

Contents

require 'selenium-webdriver'
require 'capybara/cucumber'


##
#Monkey Patch's - Use with care!
#
class Capybara::Selenium::Node
  def style(prop)
    native.style(prop)
  end
end

class Capybara::Node::Element
  def style(prop)
    base.style(prop)
  end
end

class Capybara::Driver::Node
  def style(prop)
    raise NotImplementedError
  end
end

class Capybara::Selenium::Driver
  def cookies
    browser.manage.all_cookies
  end

  def cookie_named(name)
    browser.manage.cookie_named(name)
  end

  def delete_cookie(cookie)
    browser.manage.delete_cookie(cookie)
  end

  def delete_all_cookies
    browser.manage.delete_all_cookies
  end

  def add_cookie(attribs)
    browser.manage.add_cookie(attribs)
  end

   def delete_cookies_in_domain(domain)
    browser.manage.delete_cookies_in_domain(domain)
  end
end

module Capybara
  class Session
    ##
    # Get all cookies
    #
    # @return [Array<Hash>] list of cookies
    #
    def cookies    
      driver.cookies
    end

    ##
    # Get the cookie with the given name
    #
    # @param [String] name the name of the cookie
    # @return [Hash, nil] the cookie, or nil if it wasn't found.
    #
    def cookie_named(name)    
      driver.cookie_named(name)
    end

    def delete_cookie(cookie)
      driver.delete_cookie(cookie)
    end

    def delete_all_cookies
      driver.delete_all_cookies
    end

    def add_cookie(attribs)
      driver.add_cookie(attribs)
    end

    def delete_cookies_in_domain(domain)
      driver.delete_cookies_in_domain(domain)
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
frameworks-capybara-0.3.0.rc5 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.3.0.rc4 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.3.0.rc3 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.3.0.rc2 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.16 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.15 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.14 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.13 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.12 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.11 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.10 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.9 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.8 lib/monkey-patches/capybara-patches.rb