-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
stage: wontfixCypress does not regard this as an issue or will not implement this featureCypress does not regard this as an issue or will not implement this feature
Description
Code:
// fixture test_file.png exist
// test.spec.js
cy.uploadFile('input[type="file"]', "test_file.png", 'image/png');
// command.js
Cypress.Commands.add("uploadFile", (selector, fileUrl, type = "") => {
return cy.get(selector).then(subject => {
return cy
.fixture(fileUrl, "base64")
.then(Cypress.Blob.base64StringToBlob)
.then(blob => {
return cy.window().then(win => {
const el = subject[0];
const nameSegments = fileUrl.split("/");
const name = nameSegments[nameSegments.length - 1];
const testFile = new win.File([blob], name, { type });
const dataTransfer = new DataTransfer();
dataTransfer.items.add(testFile);
el.files = dataTransfer.files;
return subject;
});
});
});
});in 3.1.5, this code work, after update to 3.2.0 stop working.
dataTransfer.items.add(testFile);
el.files = dataTransfer.files;
// this code not trigger change
// but set files
also cypress-file-upload not working in 3.2.0 (working only drag mode)
solution from #170 (comment) not working
Metadata
Metadata
Assignees
Labels
stage: wontfixCypress does not regard this as an issue or will not implement this featureCypress does not regard this as an issue or will not implement this feature