1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

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

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

View file

@ -280,6 +280,21 @@ shared_examples_for "session" do
YAML.load(@session.body)['locale'].should == 'fi' YAML.load(@session.body)['locale'].should == 'fi'
end end
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 describe "#attach_file" do
before do before do