Reputation: 8937
I often experience the following sort of situation:
cy.visit(loginUrl);
cy.get('txtUsername');
cy.type('John Smith');
cy.get('btnLogin').click();
The page appears right away and displays the expected fields and controls, but Cypress continues to wait for several seconds for other ephemeral page-load tasks (scripts to finish loading, possibly? Trivial callouts to Google Analytics?) to complete before it begins interacting with the fields.
I would prefer for Cypress to begin interacting with the fields as soon as they are available. The total runtime of my test suite would improve dramatically if Cypress didn't wait longer than it needed to.
Upvotes: 0
Views: 3863
Reputation: 3711
It isn't the best solution, I know, but you could remove the slowing down scripts passing a onBeforeLoad
option to your visit
call. The docs say
onBeforeLoad
is called as soon as possible, before your page has loaded all of its resources. Your scripts will not be ready at this point, but it’s a great hook to potentially manipulate the page.
Upvotes: 2