Added has_content? to check for content on page

This commit is contained in:
Jonas Nicklas and Kevin Fitzpatrick 2009-11-13 21:33:40 +01:00 committed by Jonas Nicklas
parent b061056d1b
commit feb29e2d64
2 changed files with 19 additions and 0 deletions

View File

@ -61,6 +61,10 @@ class Webcat::Session
driver.body
end
def has_content?(content)
driver.find("//*[contains(child::text(),'#{content}')]").size > 0
end
private
def find_link(locator)

View File

@ -281,6 +281,21 @@ shared_examples_for "session" do
end
end
describe '#has_content?' do
it "should be true if the given content is on the page at least once" do
@session.visit('/with_html')
@session.should have_content('est')
@session.should have_content('Lorem')
@session.should have_content('Redirect')
end
it "should be false if the given content is not on the page" do
@session.visit('/with_html')
@session.should_not have_content('xxxxyzzz')
@session.should_not have_content('monkey')
end
end
describe "#attach_file" do
before do
@session.visit('/form')