页面有时不会从cy.visit()加载。
经过几个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论