使用cypress上载/导入Excel文件 [英] Excel file upload/import using cypress

查看:53
本文介绍了使用cypress上载/导入Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的UI类似于

我需要将放置在Fixture文件夹中的xlsx文件上传到应用程序.有任何建议如何使用赛普拉斯吗?

I need to upload a xlsx file which I have placed in fixture folder in to the application. Any suggestions how to do it using cypress?

推荐答案

这是我发现的解决方案

  1. 安装cypress-file-upload

  1. Install cypress-file-upload

npm install --save-dev cypress-file-upload

npm install --save-dev cypress-file-upload

在命令.js文件中添加以下内容

Add following to command .js file

import'cypress-file-upload';

import 'cypress-file-upload';

使用cy.attachFile

Use cy.attachFile

const yourFixturePath ='data.json';cy.get('[data-cy ="file-input"]').attachFile(yourFixturePath);

const yourFixturePath = 'data.json'; cy.get('[data-cy="file-input"]').attachFile(yourFixturePath);

有关详细信息 https://www.npmjs.com/package/cypress-file-up

这篇关于使用cypress上载/导入Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆