使用cypress上载/导入Excel文件 [英] Excel file upload/import using cypress
问题描述
我的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?
推荐答案
这是我发现的解决方案
-
安装cypress-file-upload
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屋!