我有一个页面,我想要几个其他项目中的几个项目。所以基本上我的功能可能是这样的:
Scenario: Footer has caption Impressum
Given I am on the index page.
When I look at the footer
Then I should see a caption "Impressum"
我希望工作的是:
When /I look at the footer/ do
scope("footer") # << css selector <footer\b.*</footer>
end
Then /I should see a caption "(.*?)"/ do |caption|
within "h3" do
page.should have_content(caption)
end
end
我怎样才能尽可能可靠地实现这一点?
更详细地说,应该通过的页面是这样的:
<html>
<head></head>
<body>
<footer>
<h3>Impressum</h3>
<p>Address: Baker Street 21</p>
</footer>
</body>
</html>
虽然不应该通过的页面是这样的:
<html>
<head></head>
<body>
<h3>Impressum</h3>
<footer><p>Address: Baker Street 21</p></footer>
</body>
</html>