Class: Capybara::Mechanize::Browser
- Inherits:
-
RackTest::Browser
- Object
- RackTest::Browser
- Capybara::Mechanize::Browser
- Extended by:
- Forwardable
- Defined in:
- lib/capybara/mechanize/browser.rb
Defined Under Namespace
Classes: ResponseProxy
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#errored_remote_response ⇒ Object
readonly
Returns the value of attribute errored_remote_response.
Instance Method Summary collapse
- #current_url ⇒ Object
- #find(format, selector) ⇒ Object
-
#initialize(driver) ⇒ Browser
constructor
A new instance of Browser.
- #last_request ⇒ Object
- #last_response ⇒ Object
- #refresh ⇒ Object
- #remote?(url) ⇒ Boolean
- #reset_host! ⇒ Object
Constructor Details
#initialize(driver) ⇒ Browser
Returns a new instance of Browser.
12 13 14 15 16 17 |
# File 'lib/capybara/mechanize/browser.rb', line 12 def initialize(driver) @agent = ::Mechanize.new @agent.redirect_ok = false @agent.user_agent = default_user_agent super end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
91 92 93 |
# File 'lib/capybara/mechanize/browser.rb', line 91 def agent @agent end |
#errored_remote_response ⇒ Object (readonly)
Returns the value of attribute errored_remote_response.
91 92 93 |
# File 'lib/capybara/mechanize/browser.rb', line 91 def errored_remote_response @errored_remote_response end |
Instance Method Details
#current_url ⇒ Object
26 27 28 |
# File 'lib/capybara/mechanize/browser.rb', line 26 def current_url last_request_remote? ? remote_response.current_url : super end |
#find(format, selector) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/capybara/mechanize/browser.rb', line 83 def find(format, selector) if format==:css dom.css(selector, Capybara::RackTest::CSSHandlers.new) else dom.xpath(selector) end.map { |node| Capybara::Mechanize::Node.new(self, node) } end |
#last_request ⇒ Object
34 35 36 |
# File 'lib/capybara/mechanize/browser.rb', line 34 def last_request last_request_remote? ? OpenStruct.new(request_method: @last_method, params: @last_params) : super end |
#last_response ⇒ Object
30 31 32 |
# File 'lib/capybara/mechanize/browser.rb', line 30 def last_response last_request_remote? ? remote_response : super end |
#refresh ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/capybara/mechanize/browser.rb', line 60 def refresh if last_request_remote? process_remote_request(@last_method, @last_remote_uri.to_s, @last_params, @last_env) else register_local_request super end end |
#remote?(url) ⇒ Boolean
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/capybara/mechanize/browser.rb', line 69 def remote?(url) if Capybara.app_host true else host = URI.parse(url).host if host.nil? last_request_remote? else !Capybara::Mechanize.local_hosts.include?(host) end end end |
#reset_host! ⇒ Object
19 20 21 22 23 24 |
# File 'lib/capybara/mechanize/browser.rb', line 19 def reset_host! @last_remote_uri = nil @last_request_remote = nil @errored_remote_response = nil super end |