使用Cucumber测试在rails3上进行uploadify

我想在rails 3上的ruby上进行黄瓜测试。我试图点击capybara的上传按钮,但因为它既不是按钮也不是链接。 此外,它隐藏了text_field,所以我不能写“当我填写”上传“with”text.txt“”。 如果有人解决了这个问题,请在此处提供帮助。

编写上传文件的自定义步骤

When /^(?:|I)attach the file "([^"]*)" to "([^"]*)"$/ do |path, field| type = path.split(".")[1] case type when "jpg" type = "image/jpg" when "png" type = "image/png" when "gif" type = "image/gif" end attach_file(field, path, type) end When /^I attach the "(.*)" file at "(.*)" to "(.*)"$/ do |type, path, field| attach_file(field,path,type) end 

黄瓜一步之类

当我将文件“/images/back.gif”附加到“data_input”时

您需要编写用于上载文件的自定义步骤

 When /^I upload a file$/ do attach_file(:image, ) end 

其中image是用于获取要上载文件的html元素的名称。