Sha256: 48fa829539b3555797b3ec96dd6f41c67db8362a04a50fdad71a7ff876c2a5e5

Contents?: true

Size: 822 Bytes

Versions: 2

Compression:

Stored size: 822 Bytes

Contents

module Watir
  class Cookies
    def initialize(control)
      @control = control
    end

    def to_a
      @control.all_cookies.each do |e|
        e[:expires] = to_time(e[:expires]) if e[:expires]
      end
    end

    def add(name, value, opts = {})
      @control.add_cookie :name    => name,
                          :value   => value,
                          :secure  => opts[:secure],
                          :path    => opts[:path],
                          :expires => opts[:expires]
    end

    def delete(name)
      @control.delete_cookie(name)
    end

    def clear
      @control.delete_all_cookies
    end

    private

    def to_time(t)
      if t.respond_to?(:to_time)
        t.to_time
      else
        ::Time.local t.year, t.month, t.day, t.hour, t.min, t.sec
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-webdriver-0.5.6 lib/watir-webdriver/cookies.rb
watir-webdriver-0.5.5 lib/watir-webdriver/cookies.rb