Capybara(使用Cucumber和Selenium)attach_file在上传后重定向

时间:2012-05-31 18:49:53

标签: file-upload selenium cucumber capybara

这是我的x_steps.rb:

Given "I upload an image" do
attach_file('file','image.png')
click_button "Save Changes"
end

来自我的x.feature文件的行:

When I go to Upload page
When I upload an image

这是输入表单/字段的html

<form action="/en/upload/" method="post" id="main_form">
...
<input multiple="multiple" type="file name="file">
...
</form>

运行Selenium后转到上传页面,可能会也可能不会附加该文件。但是attach_file('file','image.png')行会导致重定向到file:///image.png。然后click_button会导致错误,因为页面上没有按钮。

有谁知道最近发生了什么? 还有上传文件的替代方案吗?

0 个答案:

没有答案