vue.js - testcafe - 上传文件

标签 vue.js testing automated-tests e2e-testing testcafe

我需要测试上传屏幕,但 .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/

相关文章:

javascript - 如何使用 vue-router 在 Vue js 中重定向到所需页面?

unit-testing - Haskell 中的内联测试用例

java - 如何对同步方法进行单元测试?

java - 如何将 WebElement 存储在 json 或属性中以便我可以轻松更改它

testing - 如何清除 Botium 中的测试 session

javascript - 需要帮助限制数组/优化 axios 响应

javascript - Vuetify - 在开关内显示文本

java - 如何在 Spock Groovy 的 THEN 阶段中预期的模拟方法调用后设置变量?

javascript - Testcafe 和 allure 记者

javascript - 使用 vue.js 将循环变量作为 HTML &lt;input&gt; onclick 属性中的函数参数传递