如何确保页面在Cypress中完全加载 [英] How to make sure page loads completely in cypress

查看:643
本文介绍了如何确保页面在Cypress中完全加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在柏树工作。
复制步骤

I am working in cypress. Steps to repro

我只是通过cy.visit()-spinner访问登录页面,正在加载
使用type-spinner传递的凭据是仍在加载
,请单击Submit.-spinner仍在加载
的抛出错误..为什么因为登录页面XHR调用未完成,这就是为什么我们仍然可以在顶部看到Spinner加载并且我尝试单击

I just visit the login page by cy.visit()-spinner is loading passed the credentials using type-spinner is still loading click on submit.-spinner is still loading its throwing error .. why because the login page XHR calls didnt get completed thats why still we can see spinner loading in top and i tried to click the submit button before it gets loaded,may be because of poor network-telling invalid credentials.

推荐答案

我相信您必须等待XHR请求以完成并验证页面加载或执行其他操作。

I believe you have to wait for the XHR request to get completed and validate the page load or perform other actions.

这里是示例,

// Wait for the route aliased as 'getAccount' to respond
cy.server()
cy.route('/accounts/*').as('getAccount')
cy.visit('/accounts/123')
cy.wait('@getAccount').then((xhr) => {
  cy.get('#loading-bar').should('not.be.visible')
})

这是一个simi我之前给出的lar解决方案-赛普拉斯:有没有办法检查元素的隐身性?

Here is a similar solution which I have previously given - Cypress:Is there any way to check invisibility of an element

这篇关于如何确保页面在Cypress中完全加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆