【发布时间】:2021-12-28 16:08:21
【问题描述】:
我有这个代码
cy.get('input[type="file"]').attachFile({
fileContent: fileContent.toString(),
fileName: 'test-image.jpeg',
mimeType: 'image/jpeg'
})
})
文件已上传,但当文件上传时,它应该显示图像的预览,但它说文件没有预览。它只是显示如下内容: https://i.stack.imgur.com/fuKAo.png
我对 pdf 有同样的问题: 我的代码是:
cy.fixture('test-pdf.PDF', "binary").then(Cypress.Blob.binaryStringToBlob).then((fileContent) => {
cy.get('input[type="file"]').attachFile({
fileContent: fileContent.toString(),
fileName: 'test-pdf.PDF',
mimeType: 'application/PDF'
})
but the preview is like this:
https://i.stack.imgur.com/ZnKpN.png
只有在 cypress 中运行测试时才会在普通浏览器中很好地加载相同的内容 我必须进行哪些更改才能使图像和 pdf 加载/预览? 谢谢
【问题讨论】:
-
您的赛普拉斯测试在哪些浏览器中运行?您是否尝试过使用其他浏览器,例如赛普拉斯运行 --browser chrome ?
-
我只在 chrome 中尝试过。我没有在firefox中测试过。我会测试并确认firefox
标签: javascript cypress