【发布时间】:2016-01-28 18:10:23
【问题描述】:
我正在尝试使用 capybara 查找 CSS 元素,但 RSpec 不断返回无法找到元素。我尝试了 id、class 和 name。
HTML(使用检查元素)
<input class="new_photo_upload_entry" type="file" name="photo_upload_entry[upload]" id="photo_upload_entry_upload">
steps.rb 文件
expect(page).to have_css('#photo_upload_entry_upload')
expect(page).to have_css('.new_photo_upload_entry')
expect(page).to have_css('input[name="photo_upload_entry[upload]"]')
运行黄瓜特征结果:
expected to find css "#photo_upload_entry_upload" but there were no matches. Also found "", which matched the selector but not all filters. (RSpec::Expectations::ExpectationNotMetError)
expected to find css ".new_photo_upload_entry" but there were no matches (RSpec::Expectations::ExpectationNotMetError)
expected to find css "input[name=\"photo_upload_entry[upload]\"]" but there were no matches. Also found "", which matched the selector but not all filters. (RSpec::Expectations::ExpectationNotMetError)
【问题讨论】:
标签: ruby-on-rails-4 cucumber capybara bdd