make link clickable
parent
48549dcaa2
commit
0736496335
|
@ -14,4 +14,12 @@ describe "Mechanize Page Link test" do
|
|||
link = page.links.first
|
||||
link.text.should eq "link text"
|
||||
end
|
||||
|
||||
it "is clickable and returns page" do
|
||||
agent = Mechanize.new
|
||||
page = agent.get("http://example.com/link")
|
||||
link = page.links.first
|
||||
page = link.click
|
||||
page.uri.to_s.should eq "http://example.com/"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -113,4 +113,10 @@ class Mechanize
|
|||
def max_history=(length)
|
||||
history.max_size = length
|
||||
end
|
||||
|
||||
# click link, and return page.
|
||||
def click(link)
|
||||
href = link.href
|
||||
get href
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,4 +12,9 @@ class MechanizeCr::PageContent::Link
|
|||
@href = node.fetch("href", "")
|
||||
@text = node.inner_text
|
||||
end
|
||||
|
||||
# click on this link
|
||||
def click
|
||||
@mech.click self
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue