问题描述
使用cypress.io测试有角度的网页时,什么是最好/最可靠的方法来检测网页何时完全加载和空闲.不只是onload事件.需要包括所有XHR请求,完整的角度摘要周期以及包括所有动画在内的所有渲染.
When using cypress.io to test an angular web page, whats the best / most reliable way to detect when the page is fully loaded and idle. Not just the onload event. Needs to include all XHR requests, angular digest cycles complete and all rendering complete including all animations complete.
原因是,在这一点上,我想测试该页面是否不包含元素,并且在上述所有步骤完全完成之前不能进行测试.
The reason is that at this point I want to test that the page does NOT contain an element and cant test that until all the above is fully complete.
推荐答案
您可以让Cypress等待任何请求完成,然后再继续.因此,如果您要等待某个页面的所有XHR,则可以对每个页面执行以下操作.等待时间由 responseTimeout配置定义.
You can make Cypress wait for any request to complete before it proceeds. So if you want to wait for all XHR of a certain page, you can do the following for each of them. How long it waits is defined by the responseTimeout configuration.
cy.server();
cy.route('**/api/getData').as('getData');
cy.visit('/home');
cy.wait('@getData');
这篇关于如何在cypress.io测试中可靠地等待页面空闲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!