Rails image_submit_tag 与黄瓜/webrat

发布于 2024-08-18 17:54:23 字数 671 浏览 4 评论 0原文

我有以下搜索表单,其中包含 image_submit_tag 而不是 Submit_tag。

现在,当黄瓜运行时,我得到了明显的失败:

When I fill in "q" with "sachin"                                               # features/step_definitions/web_steps.rb:33
And I press "submit"                                                           # features/step_definitions/web_steps.rb:21
    Could not find button "submit" (Webrat::NotFoundError)
    (eval):2:in `click_button'
    ./features/step_definitions/web_steps.rb:22:in `/^(?:|I )press "([^\"]*)"$/'
    features/search.feature:20:in `And I press "submit"'

它失败了,因为它正在寻找提交按钮。

由于我使用的是 image_submit_tag,因此该标签提交表单的 webrat/cuke 步骤是什么?

I've the following search form with image_submit_tag instead of submit_tag.

Now I get the obvious fail when cucumber runs:

When I fill in "q" with "sachin"                                               # features/step_definitions/web_steps.rb:33
And I press "submit"                                                           # features/step_definitions/web_steps.rb:21
    Could not find button "submit" (Webrat::NotFoundError)
    (eval):2:in `click_button'
    ./features/step_definitions/web_steps.rb:22:in `/^(?:|I )press "([^\"]*)"$/'
    features/search.feature:20:in `And I press "submit"'

It fails coz its looking for the submit button.

Since I'm using image_submit_tag, what will be the webrat/cuke step for this tag to make the form submit?

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

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

发布评论

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

评论(2

一张白纸 2024-08-25 17:54:23

我尝试了这个,它使用 id 选项工作:

<%= image_submit_tag "image_file_name", :id => “提交”%>

并在功能中:

然后我按“提交”

请注意 :title =>; “submit” 不起作用(尽管 Webrat 文档说它会检查 :id:title

I tried this and it works using the id option:

<%= image_submit_tag "image_file_name", :id => "submit" %>

and in the feature:

And I press "submit"

Note that :title => "submit" did not work (even though the Webrat docs says that it checks for both :id and :title)

枫林﹌晚霞¤ 2024-08-25 17:54:23

我不确定这是否有效,但请尝试向图像按钮添加 title 属性:

image_submit_tag ..., :title => "submit"

I'm not sure if this will work or not, but try adding a title attribute to your image button:

image_submit_tag ..., :title => "submit"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文