Rails image_submit_tag with cucumber/webrat

cucumberrspecruby-on-railswebrat

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?

Best Answer

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)

Related Topic