Capybara Save and Open Page Thwarted by Test Failures

The Capybara Save_and_Open_Page function, displaying the state of the page as RSpec sees it can be really helpful. So when it’s not working it could cause a productivity hit. Here’s a little tip I discovered today after reading several threads on Save_and_Open_Page not working and never once found this possible solution.

In a nutshell, Save_and_Open_Page isn’t going to open if there’s a Test Failure occurring before we call it. We’ll take a minute to walk through some screenshots and I’ll show you what may seem obvious to most, but it wasn’t to me.

Here we have a simple test, the response should contain a paragraph tag with text “You be checked out!”  No such hip response was present so we attempted to view the page as RSpec sees it with Save_and_Open_Page.

Nothing.  We see that “You be checked out!” is no where to be seen in the response, but no page display.

Okay, we know the test is failing and don’t need to be told again.  What we want is a view of the page source, dang it!

Commenting out the test this time and…BINGO! I won’t show you the web page, but trust me, removing the Test Failure restored the page display.

So comment out those failures or place save_and_open_page before them if you think save_and_open_page stopped working.

Oh, and the solution to my failed test?  I moved it to the View Test where it belonged and all was well.