Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

83
Visualizações
Cypress is not uploading the image

I am automating one of the use cases in cypress and I am unable to upload the image using attach file function. Below is the code and the snippets from HTML tags

UI Upload Image

UI Upload Image

HTML tags

HTML tags

VS code

VS code

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think you want to attach the file to the <input> as a first step. Then click the button, or you may not even have to do the click().

From the docs,

// start watching the POST requests
cy.intercept({ method: 'POST', url: /upload_endpoint/ }).as('upload');

const myFilePath = 'product.jpeg'; // file is in "/cypress/fixtures/" folder

cy.fixture(myFilePath, 'binary')
  .then(Cypress.Blob.binaryStringToBlob)
  .then(fileContent => {
    cy.get('input#productImageUpload').attachFile({
      fileContent,
      fileName: myFilePath,
      mimeType: 'application/octet-stream',
      encoding:'utf8',
      lastModified: new Date().getTime(
    })
  })

cy.get('.label-side').click()   // may not need to do this

// wait for the 'upload_endpoint' request, and leave a 2 minutes delay before throwing an error
cy.wait('@upload', { requestTimeout: 120000 });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda