我在我的场景中有这些行,第二行失败了:
Then I should see "blogger_1"
And I should not see "blogger_2"
And I should not see "blogger_2" # features/step_definitions/web_steps.rb:147
expected #has_no_content?("blogger_2") to return true, got false (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/web_steps.rb:149:in `/^(?:|I )should not see "([^"]*)"$/'
features/merge_articles.feature:46:in `And I should not see "blogger_2"'
cpybara有一个保存的页面:
答案 0 :(得分:0)
您似乎在html选项中出现了blogger_2,因此您需要更复杂的定义来检查正确位置的文本,例如https://makandracards.com/makandra/5793-test-whether-a-form-field-exists-with-cucumber-and-capybara
答案 1 :(得分:0)
我已经做了这个步骤定义来检查不在表格单元格中的单词
Then /^(?:|I )should not see "([^"]*)" in table$/ do |text|
regexp = Regexp.new('<td>'+text+'</td>')
assert page.body =~ regexp ? false : true
end