Sha256: 4f39afd72e2053f4ad814fdb214e08b19aa61678352cb95f67b53d35ce55df1a

Contents?: true

Size: 820 Bytes

Versions: 1

Compression:

Stored size: 820 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

1 entries across 1 versions & 1 rubygems

Version Path
watir-webdriver-0.5.4 lib/watir-webdriver/cookies.rb