我无法使用互联网上的所有建议代码上传图片。这是我上传区域的HTML:

我还添加了dev依赖项
//In package.json file:
"devDependencies": {
"cypress": "^3.8.3",
"cypress-file-upload": "^3.5.3"
}上传文件代码:
import 'cypress-file-upload'
//Upload a file
const fileName = 'abc.txt'
cy.fixture(fileName).then((fileContent) => {
cy.get('#root > div > div.root-container.showNotificationsBanner > div.app.modalOpened > div.modal-window.small.msg_composer > div > div:nth-child(1) > div > div > div.composerBlock.attachFiles > div > div.btn-addnew')
.wait(3000)
.upload({
fileContent, fileName, mimeType: 'input[type=text]',
},
{
subjectType: 'drag-n-drop',
},
)
cy.wait(3000)
})我没有收到任何错误,但它没有上传。
发布于 2020-08-14 05:53:18
cy.fixture(fileName).then((fileContent) => {
cy.get('[type="file"]')
.attachFile({
fileContent, fileName, mimeType: 'text/plain',
})
})https://stackoverflow.com/questions/60932522
复制相似问题