Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

83
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda