【发布时间】:2015-04-07 17:31:59
【问题描述】:
我一直在尝试针对一个简单的页面创建一个 capybara 测试用例,该页面包括一个由 country_select gem 填充的选择框。在我的测试用例中,我尝试从选择框中选择国家和生日月份,如下所示:
feature "registering for a new account" do
Capybara.javascript_driver = :poltergeist
scenario "a new user registers with a complete profile", :js => true do
page.visit '/users/sign_up'
select "United States", from: 'user[country]'
select 'January', from: 'birthMonth'
click 'sign up'
expect(response.code).to eq '200'
end
end
Capybara 或 Poltergeist 除了我默认选择的选项外,看不到任何选项。有一次我使用断言来查看我能找到哪些选项
assert_selector(:css, 'option', minimum: 20) # countries + months should be way more than 20
我得到了以下回复:
Failure/Error: assert_selector(:css, 'option', minimum: 20)
Capybara::ExpectationNotMet:
expected to find css "option" at least 20 times, found 2 matches: "country", "month"
我不知道我做错了什么。
【问题讨论】:
标签: rspec capybara rspec-rails poltergeist