Class: Capybara::Mechanize::Driver
- Inherits:
-
Object
- Object
- Capybara::Mechanize::Driver
- Defined in:
- lib/kimurai/capybara_ext/mechanize/driver.rb
Instance Method Summary collapse
- #add_header(name, value) ⇒ Object
- #clear_cookies ⇒ Object
-
#current_memory ⇒ Object
Reset parent method ‘current_memory` for mechanize (we can’t measure memory of Mechanize driver).
- #get_cookies ⇒ Object
- #headers ⇒ Object
- #headers=(headers) ⇒ Object
- #pid ⇒ Object
- #port ⇒ Object
- #quit ⇒ Object
- #set_cookie(name, value, options = {}) ⇒ Object
- #set_cookies(cookies) ⇒ Object
-
#set_proxy(ip, port, type, user = nil, password = nil) ⇒ Object
Extend capybara-mechnize to support Poltergeist-like methods www.rubydoc.info/gems/poltergeist/Capybara/Poltergeist/Driver.
Instance Method Details
#add_header(name, value) ⇒ Object
23 24 25 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 23 def add_header(name, value) browser.agent.request_headers[name] = value end |
#clear_cookies ⇒ Object
47 48 49 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 47 def browser.agent..clear! end |
#current_memory ⇒ Object
Reset parent method ‘current_memory` for mechanize (we can’t measure memory of Mechanize driver)
60 61 62 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 60 def current_memory nil end |
#get_cookies ⇒ Object
29 30 31 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 29 def browser.agent. end |
#headers ⇒ Object
15 16 17 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 15 def headers browser.agent.request_headers end |
#headers=(headers) ⇒ Object
19 20 21 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 19 def headers=(headers) browser.agent.request_headers = headers end |
#pid ⇒ Object
64 65 66 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 64 def pid nil end |
#port ⇒ Object
68 69 70 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 68 def port nil end |
#quit ⇒ Object
53 54 55 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 53 def quit browser.agent.shutdown end |
#set_cookie(name, value, options = {}) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 33 def (name, value, = {}) [:name] ||= name [:value] ||= value = Mechanize::Cookie.new(.merge path: "/") browser.agent. << end |
#set_cookies(cookies) ⇒ Object
41 42 43 44 45 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 41 def () .each do || ([:name], [:value], ) end end |
#set_proxy(ip, port, type, user = nil, password = nil) ⇒ Object
Extend capybara-mechnize to support Poltergeist-like methods www.rubydoc.info/gems/poltergeist/Capybara/Poltergeist/Driver
8 9 10 11 |
# File 'lib/kimurai/capybara_ext/mechanize/driver.rb', line 8 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 |