Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

81
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!