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

91
Visualizações
Cypress and application using window.top

I've recently started a new mission to write e2e tests using cypress but... the application is iframe based (which I can deal with) but my issue is it also use a ton (and I mean A TON) of top.someFunction().

Those top.someFunction() are interfering with cypress since top. is considered as the cypress window and I endup with errors like top.someFunction() is not a function.

A huge refactoring doesnt seems an option from the developers perspective... I've already spent a lot of time trying to find a way to get it work but I'm starting to wonder if we shouldnt use another automation tool but I really want to use cypress...

I'm lost.

Do you have any suggestion?

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

0

You may just need to wrap your calls in a .then() to have them execute on the command chain.

In a simple test using this HTML I can call top.someFunction inside a chainer

<script>
  top.someFunction = () => 'someFunction called'
</script>
it('calls top.someFunction', () => {
  cy.visit('html/top.html');

   const result = top.someFunction() // fails with "top.someFunction is not a function"
                                     // runs too soon - visit not yet executed

  
  cy.then(() => {                    // put the call on the Cypress queue 
                                     // to get the timing right
    const result = top.someFunction()
    expect(result).to.eq('someFunction called')     // passes
  })
})
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