How can I test the page title with Capybara 2.0?

后端 未结 6 865
北荒
北荒 2020-11-27 05:32

Trying to test that page contains My Title with:

# spec/features/reports_spec.rb
require \'spec_helper\'

feature \"A         


        
6条回答
  •  不知归路
    2020-11-27 06:03

    Capybara 2.1 changed its support for querying the title element. So using have selector in to query for the title element in the head of the html doc in this fashion will fail "page.should have_selector('title', :text => 'Some text'). From what i understand the preferred method in capybara 2.1 new API is to use "page.should have_title('Some text')" to query the title element should work.

提交回复
热议问题