Class: Watir::Cookies

Inherits:
Object
  • Object
show all
Defined in:
lib/watir-webdriver/cookies.rb

Instance Method Summary collapse

Constructor Details

#initialize(control) ⇒ Cookies

Returns a new instance of Cookies.



3
4
5
# File 'lib/watir-webdriver/cookies.rb', line 3

def initialize(control)
  @control = control
end

Instance Method Details

#add(name, value, opts = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/watir-webdriver/cookies.rb', line 13

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

#clearObject



25
26
27
# File 'lib/watir-webdriver/cookies.rb', line 25

def clear
  @control.delete_all_cookies
end

#delete(name) ⇒ Object



21
22
23
# File 'lib/watir-webdriver/cookies.rb', line 21

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

#to_aObject



7
8
9
10
11
# File 'lib/watir-webdriver/cookies.rb', line 7

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