abramenal / cypress-file-upload

File upload testing made easy
https://npm.im/cypress-file-upload
MIT License
498 stars 90 forks source link

Unable to upload .xlsx file using file upload plugin #216

Closed SidharthLala1 closed 3 years ago

SidharthLala1 commented 4 years ago

I am using file upload plugin to uploag imgages , csv file which works like fine now when i am trying to upload .xlsx file it throwing an error.

image

Desired behavior:

While using the file upload plugin and using the correct Blob type and mime , i belive i should be able to upload the .xlsx file format.

Steps to reproduce: (app code and test code)

cy.fixture('asin_xlsx.xlsx', 'binary') .then(Cypress.Blob.base64StringToBlob) .then(fileContent => { cy.get('input[type=file]').upload({ fileContent, fileName: 'asin_xlsx.xlsx', mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', encoding: 'utf-8', }) })

Versions

Cypress version 5.0 , Windows 64 bit , Windows 10 Pro https://www.loom.com/share/da6acb11bc70424a9346dca35338fc38

craiga commented 4 years ago

Is this a duplicate of (or at least related to) #214 ?

josephzidell commented 4 years ago

@SidharthLala1 Does this work in Cypress v4.12.1?

josephzidell commented 4 years ago

Alternatively, please test against v4.1.0

saschwarz commented 4 years ago

My pre-5.0 code for this uses Cypress.Blob.binaryStringToBlob and works:

      cy.fixture('simple_2017.xlsx', 'binary')
        .then(Cypress.Blob.binaryStringToBlob)
        .then((fileContent) => {
          cy.get('input[data-testid=pnl-input]').attachFile({
            fileContent,
            fileName: 'simple_2017.xlsx',
            mimeType:
              'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            encoding: 'utf8',
          })
        })

I don't think .xlsx files are base64 encoded

ifilatov commented 3 years ago

@saschwarz does the snippet you shared work for you on current versions? I have cypress-file-upload 4.1.1 and cypress 6.2.1 and sadly it does not work for me (no errors thrown on Cypress side, but my app UI thrown an error that was not able to parse xlsx and find excelSheet)

abramenal commented 3 years ago

Don't think this is relevant anymore. Feel free to reopen if you still experience this.