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-1.1.1 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-1.1.0 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-1.0.0 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.34 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.33 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.32 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.31 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.30 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.29 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.28 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.27 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.25 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.24 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.23 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.22 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.21 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.20 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.19 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.18 lib/monkey-patches/capybara-patches.rb
frameworks-capybara-0.2.17 lib/monkey-patches/capybara-patches.rb