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:
parent
b061056d1b
commit
feb29e2d64
2 changed files with 19 additions and 0 deletions
|
@ -60,6 +60,10 @@ class Webcat::Session
|
|||
def body
|
||||
driver.body
|
||||
end
|
||||
|
||||
def has_content?(content)
|
||||
driver.find("//*[contains(child::text(),'#{content}')]").size > 0
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -280,6 +280,21 @@ shared_examples_for "session" do
|
|||
YAML.load(@session.body)['locale'].should == 'fi'
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue