Cypress.io - 等待页面加载完成的时间过长
Cypress.io - Waiting Too Long for Pages to Finish Loading
我经常遇到以下几种情况:
cy.visit(loginUrl);
cy.get('txtUsername');
cy.type('John Smith');
cy.get('btnLogin').click();
页面立即出现并显示预期的字段和控件,但 Cypress 继续等待几秒钟以完成其他短暂的页面加载任务(可能是完成加载的脚本?对 Google Analytics 的琐碎标注?)在开始与字段交互之前完成。
我希望 Cypress 在字段可用时立即开始与这些字段进行交互。如果 Cypress 的等待时间不超过需要的时间,我的测试套件的总运行时间将会显着提高。
我知道这不是最佳解决方案,但您可以删除将 onBeforeLoad
选项传递给 visit
调用的减速脚本。 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.
我经常遇到以下几种情况:
cy.visit(loginUrl);
cy.get('txtUsername');
cy.type('John Smith');
cy.get('btnLogin').click();
页面立即出现并显示预期的字段和控件,但 Cypress 继续等待几秒钟以完成其他短暂的页面加载任务(可能是完成加载的脚本?对 Google Analytics 的琐碎标注?)在开始与字段交互之前完成。
我希望 Cypress 在字段可用时立即开始与这些字段进行交互。如果 Cypress 的等待时间不超过需要的时间,我的测试套件的总运行时间将会显着提高。
我知道这不是最佳解决方案,但您可以删除将 onBeforeLoad
选项传递给 visit
调用的减速脚本。 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.