add current_page and back
parent
316a3de570
commit
76d09d6802
|
@ -91,4 +91,13 @@ describe "Mechanize Agent test" do
|
||||||
agent.history.size.should eq 2
|
agent.history.size.should eq 2
|
||||||
agent.history.last.title.should eq "page_title"
|
agent.history.last.title.should eq "page_title"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "can back previous page" do
|
||||||
|
agent = Mechanize.new
|
||||||
|
agent.get("http://example.com/")
|
||||||
|
agent.get("http://html_example.com/")
|
||||||
|
agent.current_page.title.should eq "page_title"
|
||||||
|
agent.back
|
||||||
|
agent.current_page.title.should eq ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,6 +60,14 @@ class Mechanize
|
||||||
@agent.request_headers = request_headers
|
@agent.request_headers = request_headers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_page
|
||||||
|
@agent.current_page
|
||||||
|
end
|
||||||
|
|
||||||
|
def back
|
||||||
|
@agent.history.pop
|
||||||
|
end
|
||||||
|
|
||||||
def submit(form)
|
def submit(form)
|
||||||
case form.method.upcase
|
case form.method.upcase
|
||||||
when "POST"
|
when "POST"
|
||||||
|
|
|
@ -37,6 +37,10 @@ module MechanizeCr
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_page
|
||||||
|
@history.last
|
||||||
|
end
|
||||||
|
|
||||||
def back
|
def back
|
||||||
@history.pop
|
@history.pop
|
||||||
end
|
end
|
||||||
|
@ -102,10 +106,6 @@ module MechanizeCr
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def current_page
|
|
||||||
@history.last
|
|
||||||
end
|
|
||||||
|
|
||||||
private def reset_request_header_cookies
|
private def reset_request_header_cookies
|
||||||
request_headers.delete("Cookie")
|
request_headers.delete("Cookie")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue