我需要测试上传屏幕,但 .setFilesToUpload 遇到问题。没有文件正在上传。
编辑:如果我调试、解锁页面,单击上传文件并选择任何其他文件,该字段将填充脚本的文件
我试过了
.setFilesToUpload(Selector('input').withAttribute('type','file'), '../src/assets/logo.png')
和
.setFilesToUpload(Selector("#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 来调用我的脚本,这只是在输入上。
非常感谢
关于vue.js - testcafe - 上传文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57582963/