vue.js - testcafe - 上传文件
问题描述
我需要测试上传屏幕,但 .setFilesToUpload 有问题。没有文件正在上传。
编辑:如果我调试,解锁页面,单击上传文件并选择任何其他文件,该字段将填充脚本文件
我试过了
.setFilesToUpload(Selector('input').withAttribute('type','file'), '../src/assets/logo.png')
和
.setFilesToUpload(选择器(“#customInputFile”),“../src/assets/icon.png”)
但在这两种情况下,都没有上传文件。屏幕等待它,但没有任何反应。
<template>
<div>
<div class="file-container" v-if="!image">
<label>{{ label }}</label>
<div class="input-group">
<input
type="text"
@dragover="handleDragAndDrop"
@dragenter="handleDragAndDrop"
@dragleave="handleDragAndDrop($event, true)"
@drop="onFileChange"
v-bind:class="{ error: dataError }"
:placeholder="dataPlaceholder"
:value="dataFileName"
readonly
/>
<span class="input-group-btn">
<button class="file-button" type="button" @click="launchFilePicker">
SELECT A FILE
</button>
</span>
</div>
<input
type="file"
:value="filePayload"
@input="onFileChange"
ref="file"
id="customInputFile"
style="display: none"
/>
<span v-if="dataError" class="errorMessage">{{ dataErrorMessage }}</span>
</div>
<div class="file-container" v-else>
<img :src="image" />
<button @click="removeImage">Remove image</button>
</div>
</div>
</template>
我需要上传文件并通过测试。
解决方案
我只需要在我的输入上添加 onChange 来调用我的脚本,这只是在输入上。
非常感谢
推荐阅读
- python - typeError 的 Sigmoid 计算问题
- c# - 在 C# 中解析 json 文件以进入所有部分和属性
- r - 使用 R 中的线性模型从接收方创建工作流时出错
- python - 为每一行屏蔽一个 numpy 数组,直到某一列
- excel - vba如何根据多列选择一组行
- python - matplotlib 动画时长 4 帧延迟
- sapui5 - 如何在视图控制器中动态更改 UI5 中的标准应用程序标签文本
- javascript - 在文本框中触发 onchange 输入
- python - DataFrame Python中的分层列
- html - 如何在 div 容器中自动裁剪和居中图像