Rails image_submit_tag 与黄瓜/webrat
我有以下搜索表单,其中包含 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试了这个,它使用
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
)我不确定这是否有效,但请尝试向图像按钮添加
title
属性:I'm not sure if this will work or not, but try adding a
title
attribute to your image button: