I have been searching for a solution to the .wait() problems I have been having in Cypress. Our application does not load all the data at the same time. The most common answer given to requests like this is as follows:
cy.server();
cy.route('**/api/getData').as('getData');
cy.visit('/home');
cy.wait('@getData');
This simply does not work. You will arrive at /customer/12345 and yet it may be several more seconds before the entirety of the data has loaded, even some UI elements. So, checking for the route doesn't help at all. I tried to create an alias but when I do something like this:
cy.get('#submitButton').as('submit')
And then do:
cy.wait('@submit')
It fails the alias check because the button is not present yet.
I need to wait until all the resources are loaded before I can start testing the elements. A developer on my team who does not have any understanding of Cypress asked if I could use the Window load event or the GlobalEventHandler.onload, but I couldn't find any documentation on using these in Cypress.
One thing I would like any answerers to understand, I am a total newbie. I have experience with Java, Selenium, Unirest, and Junit. I am having to completely change my mindset with Cypress and I do not know Javascript, so I'm still in the learning phase on this. In Selenium I would have
wait.until(ExpectedConditions.elementToBeClickable(By.id<submitButton>));
So, is there a way for me to make sure the entirety of the resources are loaded before it starts running the tests?