Class: Capybara::Mechanize::Browser
- Inherits:
-
Object
- Object
- Capybara::Mechanize::Browser
- Defined in:
- lib/capybara/mechanize/browser.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
Instance Method Summary collapse
- #been_somewhere? ⇒ Boolean
- #delete(url) ⇒ Object
- #dom ⇒ Object
- #get(url) ⇒ Object
- #headers ⇒ Object
-
#initialize ⇒ Browser
constructor
A new instance of Browser.
- #post(url) ⇒ Object
- #put(url) ⇒ Object
- #source ⇒ Object
- #status_code ⇒ Object
- #submit(form) ⇒ Object
- #uri ⇒ Object
- #url ⇒ Object
Constructor Details
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
4 5 6 |
# File 'lib/capybara/mechanize/browser.rb', line 4 def agent @agent end |
Instance Method Details
#been_somewhere? ⇒ Boolean
47 48 49 |
# File 'lib/capybara/mechanize/browser.rb', line 47 def been_somewhere? !@agent.current_page.nil? end |
#delete(url) ⇒ Object
20 |
# File 'lib/capybara/mechanize/browser.rb', line 20 def delete(url); @agent.delete(url); end |
#dom ⇒ Object
39 40 41 |
# File 'lib/capybara/mechanize/browser.rb', line 39 def dom been_somewhere? ? @agent.current_page.root : Nokogiri::HTML(nil) end |
#get(url) ⇒ Object
13 14 15 16 |
# File 'lib/capybara/mechanize/browser.rb', line 13 def get(url) referrer = been_somewhere? ? self.url : nil @agent.get(url, [], referrer) end |
#headers ⇒ Object
31 32 33 |
# File 'lib/capybara/mechanize/browser.rb', line 31 def headers been_somewhere? ? @agent.current_page.header : {} end |
#post(url) ⇒ Object
18 |
# File 'lib/capybara/mechanize/browser.rb', line 18 def post(url); @agent.post(url); end |
#put(url) ⇒ Object
19 |
# File 'lib/capybara/mechanize/browser.rb', line 19 def put(url); @agent.get(url); end |
#source ⇒ Object
43 44 45 |
# File 'lib/capybara/mechanize/browser.rb', line 43 def source been_somewhere? ? @agent.current_page.body : '' end |
#status_code ⇒ Object
35 36 37 |
# File 'lib/capybara/mechanize/browser.rb', line 35 def status_code been_somewhere? ? @agent.current_page.code.to_i : nil end |
#submit(form) ⇒ Object
21 |
# File 'lib/capybara/mechanize/browser.rb', line 21 def submit(form); @agent.submit(form); end |
#uri ⇒ Object
23 24 25 |
# File 'lib/capybara/mechanize/browser.rb', line 23 def uri been_somewhere? ? @agent.current_page.uri : nil end |
#url ⇒ Object
27 28 29 |
# File 'lib/capybara/mechanize/browser.rb', line 27 def url uri.nil? ? '' : uri.to_s end |