-1

First click and select from dropdown how to upload file like computer or drive, after selecting computer i have to upload from my computer in cypress. I'm trying this way it's not working, No action after clicking

cy.get(this.business_registration).click()
cy.fixture('images.png').then(fileContent => {
        cy.get(this.select_browse).attachFile({
             fileContent,
             fileName: 'images.png',
             mimeType: 'image/png'
          });
     });

enter image description here enter image description here

What is the way to do it with Cypress?

  • 2
    Please do not [repeat questions](https://stackoverflow.com/questions/76828233/cypress-file-upload-issue). Instead you should modify existing questions if you have more details the add. – T.Soithongsuk Aug 09 '23 at 06:28
  • 1
    You should also provide feedback to users kind enough to give you a reply. – T.Soithongsuk Aug 09 '23 at 06:29
  • 1
    Does this answer your question? [Cypress file upload issue](https://stackoverflow.com/questions/76828233/cypress-file-upload-issue) – T.Soithongsuk Aug 09 '23 at 06:29
  • The difference is, in the previous method, you had to click and then upload the file, and now, you have to select how to upload the file first, like you have to select Browse first and then upload. – Nazmul Hossain Aug 09 '23 at 06:33

1 Answers1

4

It appears you have neglected the advice from the answer to your previous question.

You have not used Blob conversions .then(Cypress.Blob.base64StringToBlob) as given by @ryry and also given by Cypress themselves here Image Fixture

// programmatically upload the logo
cy.fixture('images/logo.png').as('logo')
cy.get('input[type=file]').then(function ($input) {
  // convert the logo base64 string to a blob
  const blob = Cypress.Blob.base64StringToBlob(this.logo, 'image/png')

  // pass the blob to the fileupload jQuery plugin
  // https://github.com/blueimp/jQuery-File-Upload
  // used in your application's code
  // which initiates a programmatic upload
  $input.fileupload('add', { files: blob })
})

Also, it seems that the .click() you refer to is not changing the basis of the question.

Vagdevi
  • 119
  • 9