title: Ensure an element is not present with Capybara
body: <p>Using Capybara, I need to assert that a form element is not present, for example, 'Then I should not see the "Username" text field'. As find throws an exception if the element isn't found, this is the best I've come up with. Is there a better way?</p>
  
  <pre class="lang-rb prettyprint-override"><code>Then /^I should not see the "([^\"]+)" ([^\s]+) field$/ do |name, type|
    begin
      # Capybara throws an exception if the element is not found
      find(:xpath, "//input[@type='#{type}' and @name='#{name}']")
      # We get here if we find it, so we want this step to fail
      false
    rescue Capybara::ElementNotFound
      # Return true if there was an element not found exception
      true
    end 
  end
  </code></pre>
  
  <p>I'm new to Capybara, so I may be missing something obvious.</p>