Capybara can match elements outside of <body>

Updated . Posted . Visible to the public.

Capybara will match elements outside of a page's <body> tag.

For example, the step definitions below match <link> nodes in a page's <head>:

Then /^my browser should auto-discover the "([^"]*)" feed$/ do |slug|
  page.should have_css(
    'head link' +
    '[rel="alternate"]' +
    "[href='http://www.example.com/#{slug}/feed.rss']" +
    '[title="RSS feed (all cards)"]' +
    '[type="application/rss+xml"]',
    visible: false
  )
end

Then /^my browser should not auto-discover any RSS feeds$/ do
  page.should_not have_css('head link[rel="alternate"][type="application/rss+xml"]')
end
Profile picture of Henning Koch
Henning Koch
Last edit
Dominik Schöler
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2011-10-14 09:30)