cypresscypress-file-upload

File upload with cypress is not working for PDF


Although it looks as if the file uploaded, it didn`t. Can someone tell me how I can upload a pdf file with Cypress?

cy.get("div.button")
  .attachFile({
     filePath:'form.pdf',
     mimeType:'application/pdf',
     encoding:"base64"
   },
   {
     force:true,
     uploadType:"input"
   })

enter image description here


Solution

  • cy.get(div.button) seems like you are targetting the wrong element. The correct element must be of type input not type div

    Take a close look at the HTML to find the correct selector