I faced the same problems. Empirically, the following is what I found:
page.should have_selector("title", :text => "AnyTitle")
expects your html output to contain a tag as shown below:
<title text="AnyTitle"/>
however, if you use: content instead of: text below
page.should have_selector("title", :content => "AnyTitle")
then it expects your html output to contain the tag below
<title>AnyTitle</title>
So, if your final html rendering contains the <title text="AnyTitle"/> , you should use: text otherwise, if the resulting html rendering contains the <title>AnyTitle</title> , you can use: content instead.
PS my environment Gem: Capybara-2.0.2, Rails-3.2.12, RSpec rails-2.12.2, Webrat-0.7.3 if you remove webrat, then the keyword ": conetnt" is not recognized only by Capybara.
But a clean way to fix it: get rid of webrat and install stable Capybara-1.1.2, which is located in the Gemfile
#gem webrat gem 'capybara', '1.1.2'
refer to prusswan answer
Paul wang
source share