水豚:如何附加文件?
Capybara: How to attach a file?
我有一个元素,点击它我打开添加图片的对话框window:
<div layout="column" class="uploadPhotoActionBlock layout-align-center-center layout-column" layout-align="center center" ngf-select="vm.addPhotos($file)"
accept="image/*" ng-hide="vm.product.images.length == 3" aria-hidden="false"> <div flex="" class="plus flex"> + </div> <div flex="" class="text ng-binding flex"> add photo </div> </div>
我需要在测试中执行这些步骤。
我试过了:
- attach_file
- find.set
- 点击按钮+点击(在window内点击)
没有任何效果。
浏览器是 Chrome。
有什么想法吗?谢谢
您需要使与 AddPhoto 小部件关联的实际 <input type="file">
元素可见(您不会在 html 中显示实际输入),然后调用 attach_file .通常这意味着使用 execute_script
调整输入元素的 CSS 以使其可见。
我有一个元素,点击它我打开添加图片的对话框window:
<div layout="column" class="uploadPhotoActionBlock layout-align-center-center layout-column" layout-align="center center" ngf-select="vm.addPhotos($file)"
accept="image/*" ng-hide="vm.product.images.length == 3" aria-hidden="false"> <div flex="" class="plus flex"> + </div> <div flex="" class="text ng-binding flex"> add photo </div> </div>
我需要在测试中执行这些步骤。
我试过了:
- attach_file
- find.set
- 点击按钮+点击(在window内点击)
没有任何效果。
浏览器是 Chrome。
有什么想法吗?谢谢
您需要使与 AddPhoto 小部件关联的实际 <input type="file">
元素可见(您不会在 html 中显示实际输入),然后调用 attach_file .通常这意味着使用 execute_script
调整输入元素的 CSS 以使其可见。