title: Best practice for checking for error messages using Page Objects
body: <p>Best practice for checking for error messages using Page Objects. So I have duplication in regards to my code where I'm checking for various error messages. My question is using Page Objects/page_objects gem, is there a way I can remove this duplication? My code:</p>
  
  <pre><code>def check_error_message
    expected_text = "The highlighted fields must be filled out correctly."
    css = "button-error"
    actual_text = @browser.span(:class, css).text
  
    actual_text.should == expected_text
    puts "Span class '#{css}' expected text: #{expected_text}"
    puts "Span class '#{css}' actual text: #{actual_text}"
  end
  
  def check_password_weak_message
    expected_text = "Password is too weak, please choose a different password."
    css = "formError"
    actual_text = @browser.div(:class, css).text
  
    actual_text.should == expected_text
    puts "Span class '#{css}' expected text: #{expected_text}"
    puts "Span class '#{css}' actual text: #{actual_text}"
  end
  
  def check_dupe_email_message
    expected_text = "This email address is already in use by another ID.me account"
    css = "label-error"
    actual_text = @browser.div(:class, css).text
  
    actual_text.should == expected_text
    puts "Span class '#{css}' expected text: #{expected_text}"
    puts "Span class '#{css}' actual text: #{actual_text}"
  end
  </code></pre>
  
  <p>Things that change in the methods: expected_text, css, actual_text.</p>