页面有时不会从cy.visit()加载。

发布于 2025-02-13 17:57:38 字数 1087 浏览 1 评论 0原文

经过几个IT障碍后,Cy.visit()停止尝试加载URL,并且由于对页面加载的断言,测试失败。有人遇到过这个问题,并为此提供任何解决方案。

我的代码就是这样:

    describe('Check stuff', () => {
  const password = Cypress.env('PASSWORD');
  const user1 = Cypress.env('USERS_US')['USER1']['USERNAME']

    beforeEach(() => {
      cy.login(user1, password);
    });

    afterEach(() => {
      // Log out
      cy.visit('/logout');
    });

    it('check1', () => {
    // Direct to report page
      cy.visit('url1');
      cy.url().should('contain', 'url1');

      });

    it('check2', () => {
    // Direct to report page
      cy.visit('url2');
      cy.url().should('contain', 'url2');

      });

    it('check3', () => {
    // Direct to report page
      cy.visit('url3');
      cy.url().should('contain', 'url3');

      });

    it('check4', () => {
    // Direct to report page
      cy.visit('url4');
      cy.url().should('contain', 'url4');

      });
    it('check5', () => {
    // Direct to report page
      cy.visit('url5');
      cy.url().should('contain', 'url5');

      });
});

After a few it block, cy.visit() stop attempting to load the url and the test fails due to assertions regarding page loading. Has anyone come across this and has any solution to this.

my code is something like this:

    describe('Check stuff', () => {
  const password = Cypress.env('PASSWORD');
  const user1 = Cypress.env('USERS_US')['USER1']['USERNAME']

    beforeEach(() => {
      cy.login(user1, password);
    });

    afterEach(() => {
      // Log out
      cy.visit('/logout');
    });

    it('check1', () => {
    // Direct to report page
      cy.visit('url1');
      cy.url().should('contain', 'url1');

      });

    it('check2', () => {
    // Direct to report page
      cy.visit('url2');
      cy.url().should('contain', 'url2');

      });

    it('check3', () => {
    // Direct to report page
      cy.visit('url3');
      cy.url().should('contain', 'url3');

      });

    it('check4', () => {
    // Direct to report page
      cy.visit('url4');
      cy.url().should('contain', 'url4');

      });
    it('check5', () => {
    // Direct to report page
      cy.visit('url5');
      cy.url().should('contain', 'url5');

      });
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文