Sha256: 4f404c1a2659949f07f0e62866e970a4b23315a0135633d8b33f510e545f2fb6

Contents?: true

Size: 823 Bytes

Versions: 3

Compression:

Stored size: 823 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(dt)
      if dt.respond_to?(:to_time)
        dt.to_time
      else
        Time.local t.year, t.month, t.day, t.hour, t.min, t.sec
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
watir-webdriver-0.5.3 lib/watir-webdriver/cookies.rb
watir-webdriver-0.5.2 lib/watir-webdriver/cookies.rb
watir-webdriver-0.5.1 lib/watir-webdriver/cookies.rb