Skip to content

File upload on input, stop working in Chrome 73 #3730

@DragorWW

Description

@DragorWW

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

No one assigned

    Labels

    stage: wontfixCypress does not regard this as an issue or will not implement this feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions