Class: Capybara::Mechanize::Driver

Inherits:
Object
  • Object
show all
Defined in:
lib/kimurai/capybara_ext/mechanize/driver.rb

Instance Method Summary collapse

Instance Method Details

#add_header(name, value) ⇒ Object



22
23
24
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 22

def add_header(name, value)
  browser.agent.request_headers[name] = value
end

#clear_cookiesObject



46
47
48
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 46

def clear_cookies
  browser.agent.cookie_jar.clear!
end

#current_memoryObject

Reset parent method ‘current_memory` for mechanize (we can’t measure memory of Mechanize driver)



59
60
61
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 59

def current_memory
  nil
end

#get_cookiesObject



28
29
30
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 28

def get_cookies
  browser.agent.cookies
end

#headersObject



14
15
16
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 14

def headers
  browser.agent.request_headers
end

#headers=(headers) ⇒ Object



18
19
20
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 18

def headers=(headers)
  browser.agent.request_headers = headers
end

#pidObject



63
64
65
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 63

def pid
  nil
end

#portObject



67
68
69
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 67

def port
  nil
end

#quitObject



52
53
54
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 52

def quit
  browser.agent.shutdown
end


32
33
34
35
36
37
38
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 32

def set_cookie(name, value, options = {})
  options[:name]  ||= name
  options[:value] ||= value

  cookie = Mechanize::Cookie.new(options.merge(path: '/'))
  browser.agent.cookie_jar << cookie
end

#set_cookies(cookies) ⇒ Object



40
41
42
43
44
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 40

def set_cookies(cookies)
  cookies.each do |cookie|
    set_cookie(cookie[:name], cookie[:value], cookie)
  end
end

#set_proxy(ip, port, _type, user = nil, password = nil) ⇒ Object



7
8
9
10
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 7

def set_proxy(ip, port, _type, user = nil, password = nil)
  # type is always "http", "socks" is not supported (yet)
  browser.agent.set_proxy(ip, port, user, password)
end