---
title: Multiline strings in Capybara
teaser:
tags: web,testing
author: Gabe Berke-Williams
published_on: 2011-08-02
---

When checking for a multiline string in
[Capybara](https://github.com/jnicklas/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`. Here's a sample Cucumber step definition:

```ruby
Then /^I should see:$/ do |text|
  page.text.should include text
end
```
