Я хочу протестировать функцию добавления изображения в приложение. Как я могу это сделать. метод attach_file не работает. Я не знаю почему.
HTML:
<form id="edit_user_5577b0c4a851ac600c000002" class="form-horizontal user-settings" method="post" enctype="multipart/form-data" action="/tardis54" accept-charset="UTF-8">
<div id="upload-avatar" class="control-group">
::before
<label class="control-label" for="user_avatar">
Setting avatar
</label>
<div class="controls">
<div class="form-fileupload">
<div class="image-preview">
<img class="gravatar img-circle" width="60" height="60" src="http://gravatar.com/avatar/7046a07b25397e4a0c838a47c88d8742?default=identicon&secure=false&size=60" data-retina-url="http://gravatar.com/avatar/7046a07b25397e4a0c838a47c88d8742?default=identicon&secure=false&size=120" alt="tardis54"></img>
</div>
<span class="btn btn-fileinput btn-default">
<span>
Choose file ...
</span>
<input id="user_avatar" class="input-file" type="file" name="user[avatar]"></input>
</span>
</div>
</div>
</div>
<div class="form-actions pull-right">
<input class="btn btn-large btn-primary" type="submit" value="Update" name="commit"></input>
</div>
</form>
тестовый код:
scenario "upload a custom avatar" do
attach_file("user[avatar]", Rails.root + "temp4.png")
end
журнал ошибок:
Failure/Error: attach_file("user[avatar]", Rails.root + "temp4.png")
Capybara::Webkit::ClickFailed:
Failed to click element /html/body/div[@id='content']/div/div/div/div/div/div[2]/form[@id='edit_user_5580e19da851ac6a51000002']/div[@id='upload-avatar']/div/div/span/input[@id='user_avatar']
because of overlapping element /html/body/div[@id='content']/div/div/div/div/div at position 740, 627;
id
в качестве локатора и дайте мне знать, что произойдет - person Richlewis   schedule 17.06.2015attach_file("user_avatar", Rails.root + "temp4.png")
. Получите ту же ошибку, что и раньше. - person tardis   schedule 17.06.2015attach_file("#user_avatar", Rails.root + "temp4.png")
- person Richlewis   schedule 17.06.2015attach_file("#user_avatar", Rails.root + "temp4.png")
. Я получаю сообщение об ошибке:Capybara::ElementNotFound: Unable to find file field "#user_avatar"
- person tardis   schedule 17.06.2015"#{Rails.root}/path/to/image"
- person Richlewis   schedule 17.06.2015