【发布时间】:2021-10-17 08:45:54
【问题描述】:
我有一个接受文件并使用cypress-file-upload 的表单,我让它正常工作。但是我也有一个场景,当没有文件上传时我需要验证错误。包本身正在验证文件是否存在。在这种情况下我们如何测试?
cy.get('input[type="file"]').attachFile();// Cannot read property 'filePath' of undefined
cy.get('input[type="file"]').attachFile(""); //missing "filePath" or "fileName".
Please make sure you are passing either "filePath" or "fileName"
cy.get('input[type="file"]').attachFile("expense1.json")//Works for the positive case
cy.get(".alert").should('be.visible').and('contain', "You poor guy did not upload a file...")
【问题讨论】:
-
您只需单击上传按钮,无需选择任何内容。那么它会给你提示信息吗?
-
不,我只有一个按钮,我没有上传按钮
标签: cypress cypress-file-upload