I am trying to automate a website where the testing environment is reduced and the page loads nearly two minutes(120000). I don't want to use cy.wait(120000) or cy.pause() command. Could anyone help by giving more suggestions to solve the issue even the testing environment gets slower than this. I have tried should,intercept,etc..,Other than the normal ones can someone suggest me some ideas.It wil be more helpful if you post your answers with commands.
Advance Thanks for making a try to solve this.
cy.wait is not a good practice in most situations because it just hangs your program to wait till the end of the timeout.
I think you're looking for a solution to wait for an element appears in HTML, so I'd suggest you to check this part of the document
In your case, it should be like below
cy.get('.selector', { timeout: 120000 }).should('be.visible')
Even though the timeout is longer but whenever your .selector appears on the HTML, it will pass.
Note that, the default timeout is only 4 seconds, so if you want to have more timeout, you can modify it to longer (like 2 mins for your case).
Why do we need to have timeout? Well, basically, we don't want the program hangs forever, so that's why we need to have timeout.