Ask Cucumber with Capybara for inline HTML... now with CSS Selectors!

By: Johnathon Wright on: January 18, 2011

Two very useful cucumber steps:

Then 'display the page' do puts "\n\n\n#{page.body.to_s}\n\n\n" end

Then /^display "([^"]*)"$/ do |selector| puts "\n\n\n#{find(selector).native.to_html}\n\n\n"


When you're remoting in to your dev machine, you can't use "Then show me the page" because there is no desktop in which to open the browser... so I created "Then display the page". It outputs the HTML to the screen for your examination. This becomes very tedious when pages get long... after some help on the capybara mailing list, I created the second entry, which accepts a CSS selector.


Just checking that you are human. What would be the result of this code?

a = 3*(4/2); b = 1; a+b

Jack said: We will remove all packing materials, including boxes and wrapping paper, leaving your new home clean and clutter-free. Auto Transport Rates Schuyler County