Read more

Capybara can match elements outside of <body>

Henning Koch
October 14, 2011Software engineer at makandra GmbH

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

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

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
Posted by Henning Koch to makandra dev (2011-10-14 11:30)