click_link with text

This commit is contained in:
Jonas Nicklas 2009-11-05 00:49:17 +01:00
parent 233f9fbbd5
commit 5961cac9d6
2 changed files with 11 additions and 1 deletions

View File

@ -22,7 +22,9 @@ class Webcat::Session
end
def click_link(locator)
driver.find("//a[@id='#{locator}']").first.click
link = driver.find("//a[@id='#{locator}']").first
link ||= driver.find(%{//a[text()="#{locator}"]}).first
link.click
end
def body

View File

@ -25,6 +25,14 @@ describe Webcat::Session do
@session.body.should == 'Another World'
end
end
context "with text given" do
it "should take user to the linked page" do
@session.visit('/with_html')
@session.click_link('labore')
@session.body.should == '<h1>Bar</h1>'
end
end
end
end