Class: Watir::Cookies

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

Instance Method Summary (collapse)

Constructor Details

- (Cookies) initialize(control)

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

- (Object) add(name, value, opts = {})



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/watir-webdriver/cookies.rb', line 13

def add(name, value, opts = {})
  cookie = {
    :name    => name,
    :value   => value,
    :secure  => opts[:secure],
    :path    => opts[:path],
    :expires => opts[:expires],
  }

  if opts[:domain]
    cookie[:domain] = opts[:domain]
  end

  @control.add_cookie cookie
end

- (Object) clear



33
34
35
# File 'lib/watir-webdriver/cookies.rb', line 33

def clear
  @control.delete_all_cookies
end

- (Object) delete(name)



29
30
31
# File 'lib/watir-webdriver/cookies.rb', line 29

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

- (Object) to_a



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