Excel file upload/import using cypress

雨燕双飞 提交于 2021-02-10 15:15:59

问题


I've a UI similar to

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:


This what I found as the solution

  1. Install cypress-file-upload

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

  2. Add following to command .js file

    import 'cypress-file-upload';

  3. Use cy.attachFile

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

For details https://www.npmjs.com/package/cypress-file-upload



来源:https://stackoverflow.com/questions/62206500/excel-file-upload-import-using-cypress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!