加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何检查表列是否给出了文本?

发布时间:2020-12-17 02:35:38 所属栏目:百科 来源:网络整理
导读:我正在做作业,需要检查 HTML表格栏是否给出了文字.我从web_steps.rb复制了示例并尝试更改以满足我的需要,但测试失败. 步: And I should not see 'G' 步骤定义失败: Then /^(?:|I )should not see '([^']*)'$/ do |text| save_and_open_page if page.respon
我正在做作业,需要检查 HTML表格栏是否给出了文字.我从web_steps.rb复制了示例并尝试更改以满足我的需要,但测试失败.
步:

And I should not see 'G'

步骤定义失败:

Then /^(?:|I )should not see '([^']*)'$/ do |text|
  save_and_open_page
  if page.respond_to? :should
    page.find('#movies').should have_no_content(text)
  else
    assert page.find('#movies').has_no_content?(text)
  end  
end

错误是:

expected #has_no_content?(“G”) to return true,got false
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/movie_steps.rb:35:in /^(?:|I )should not see '([^']*)'$/'
features/filter_movie_list.feature:37:in
And I should not see ‘G”

电影是桌子的id.

表看起来像:

我被困在这里,无法走得更远.有人能给我一些提示来解决这个问题吗?

解决方法

您可以尝试:

assert page.find('#movies').has_no_content?(">#{text}<")

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读