Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:03:54+00:00 2026-06-07T09:03:54+00:00

I have a webpage that I display in a printer friendly format with headlines

  • 0

I have a webpage that I display in a printer friendly format with headlines followed by items belonging to that group.
Example:

Headline1
=========
Item1
Item2
Item3

Headline2
=========
Item4
Item5

I want to use cucumber + capybara to run feature test and verify that the page has correct content.
How would I do that as simple as possible? Since I want to make sure that each item has ended up under the correct headline.

My first attempt was by using

page.should have_content"Headline1
=========
Item1
Item2
Item3

Headline2
=========
Item4
Item5"

But that gives me a strange error:

expected there to be content "Headline1\n=========\nItem1\n and so on" in "Headline1\n=========\nItem1\n and so on"

In other words the two lines is exactly the same!!! Why does this not work?
Any workaround?
Note that the page contains of only basic text so no div items or such that I can check within.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:03:55+00:00Added an answer on June 7, 2026 at 9:03 am

    Use page.text with include? or match methods.

    http://robots.thoughtbot.com/post/8399836754/multiline-strings-in-capybara
    http://praktikanten.brueckenschlaeger.org/2011/11/15/working-in-cucumber-with-new-lines-and-have_content

    A quote from the first link:

    When checking for a multiline string in Capybara, you need to use
    page.text because page.source does not preserve new lines – so “a\nb”
    would come out as “a b” in page.source.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage that activates a print job on a printer. This works
I have designed a webpage that can display properly in Windows XP (IE8) .
Scenario: You have an ASP.Net webpage that should display the next image in a
Hi I have a webpage that's using classic ASP that I want to display
I have webpage that need to be upated for example if the articles in
I have a webpage that displays a very large list of data. Since this
I have a webpage that displays a calendar, and I want to change the
I have a simple Web Browser Control that displays a local webpage and that
I have a webpage that redirects to another webpage like this: http://www.myOtherServer.com/Sponsor.php?RedirectPage=http://mylink.com/whereIwasgoingtogo.html Then the
I have a webpage that I don't have the ability to change the underlying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.