Sha256: 09c7e52ef2dcc157bd16509c101552119c8611a60991e44cb20dc102f864523f

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

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

#Monkey Patch's - Use with care!
#
class Capybara::Driver::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::Driver::Selenium
  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
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
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
frameworks-capybara-0.0.38 lib/monkey-patches/capybara-patches.rb