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

109
Visualizações
WinHttpRequest / Microsoft.XMLDOM vs. Cypress.Request POST

I apologize in advance for this poorly worded question.

I'm re-writing an older E2E test that performs a POST of an XML document to an internal site using vbScript. With WinHttpRequest and Microsoft.XMLDOM the data is accepted and appears as expected in the website. However, when I perform the "same" operation using Cypress I obtain different results.

My question: Is there difference in the way these two technologies perform the POST operation or am I missing something in the Cypress code?

Thanks in advance for any advice!

VBS

Dim xmlhttp, oXML
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "POST", "https://InternalWebSite.com/Orders/CXMLOrder.aspx", False
xmlhttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded; charset=UTF-8"
xmlhttp.setRequestHeader "Content-length", "1000"
xmlhttp.setRequestHeader "Connection", "close"
xmlhttp.setRequestHeader "soapAction", ""
Set oXML = CreateObject("Microsoft.XMLDOM")
oXML.async = False
oXML.load(localPath & "\MyOrderFile.xml")
xmlhttp.send(oXML)

CYPRESS

it('Post Order File to Site', () => {
    const myOrderFile = 'C:\\Automation\\MyOrderFile.xml'
    cy
        .readFile(myOrderFile)
        .then(function (text) {
            cy.log(text)
            postXML(text)
         })
    })

function postXML(text) {
    return cy.request({ 
        url: 'https://InternalWebSite.com/Orders/CXMLOrder.aspx',
        method: 'POST',
        body: text,
        headers: {
            'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'content-length': '1000',
            'connection': 'close',
            'soapAction': ''
        }
    }
)}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The solution ended up being quite simple.

In the original VBS code the "content-length" was set to 1000 - my assumption was that if it worked for VBS it would also work for Cypress. As it turns out setting "content-length" based on the actual XML payload length was the trick.

From: 'content-length': '1000',

To: 'content-length': text.length,

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