click link by title
This commit is contained in:
parent
66a5af0f56
commit
130f5a9d1b
|
@ -14,7 +14,8 @@ module Webrat
|
|||
end
|
||||
|
||||
def matches_text?(link_text)
|
||||
text =~ /#{Regexp.escape(link_text.to_s)}/i
|
||||
matcher = /#{Regexp.escape(link_text.to_s)}/i
|
||||
text =~ matcher || title =~ matcher
|
||||
end
|
||||
|
||||
def text
|
||||
|
@ -27,6 +28,10 @@ module Webrat
|
|||
authenticity_token.blank? ? {} : {"authenticity_token" => authenticity_token}
|
||||
end
|
||||
|
||||
def title
|
||||
@element['title']
|
||||
end
|
||||
|
||||
def href
|
||||
@element["href"]
|
||||
end
|
||||
|
|
|
@ -148,6 +148,14 @@ describe "clicks_link" do
|
|||
@session.clicks_link "Link text"
|
||||
end
|
||||
|
||||
it "should work with anchor titles" do
|
||||
@session.response_body = <<-EOS
|
||||
<a href="/page" title="Link title">Link text</a>
|
||||
EOS
|
||||
@session.expects(:get).with("/page", {})
|
||||
@session.clicks_link "Link title"
|
||||
end
|
||||
|
||||
it "should match the first matching link" do
|
||||
@session.response_body = <<-EOS
|
||||
<a href="/page1">Link text</a>
|
||||
|
|
Loading…
Reference in New Issue