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?
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
})
})