黄瓜应该看到按钮

发布于 2024-09-17 18:35:04 字数 330 浏览 2 评论 0原文

我有一个表单,其中包含

<%= Submit_tag 'Search Event' %>

和一个黄瓜步骤,上面写着

And I should see "Search Event"

但这一步失败了..这是为什么?

这是我得到的错误

expected #has_content?("Search Event") to return true, got false (RSpec::Expectations::ExpectationNotMetError)

I have a form that has this

<%= submit_tag 'Search Event' %>

and a cucumber step that says

And I should see "Search Event"

but this step fails.. why is that?

Here is the error i get

expected #has_content?("Search Event") to return true, got false (RSpec::Expectations::ExpectationNotMetError)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦里寻她 2024-09-24 18:35:04

编写您自己的步骤,即使用 capybara (以及 rspec):

Then /^I should see "([^"]*)" button/ do |name|
  find_button(name).should_not be_nil
end

Write your own step, i.e. using capybara (rspec as well):

Then /^I should see "([^"]*)" button/ do |name|
  find_button(name).should_not be_nil
end
白云悠悠 2024-09-24 18:35:04

我认为这不起作用,因为按钮标签不是文本内容——它是提交按钮的值属性。

I think this doesn't work because the button label is not text content -- it's the value attribute of the submit button.

蒗幽 2024-09-24 18:35:04

这项工作正面:

Then /^I should see "([^"]*)" button/ do |name|
  should have_button name
end

负面:

Then /^I should not see "([^"]*)" button/ do |name|
  should have_no_button name
end

This work in positive:

Then /^I should see "([^"]*)" button/ do |name|
  should have_button name
end

in negative:

Then /^I should not see "([^"]*)" button/ do |name|
  should have_no_button name
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文