I followed various recommendations from the internet to upload an image, but I am still encountering difficulties. Let me share the HTML of my upload section:
https://i.sstatic.net/9VAf8.png
I even included a development dependency in my codebase.
//Inside package.json:
"devDependencies": {
"cypress": "^3.8.3",
"cypress-file-upload": "^3.5.3"
}
Here is the snippet of code for uploading a file:
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)
})
No errors are being displayed, but unfortunately, the upload process doesn't seem to work as expected.