Reputation: 1
I have a process that create a quote divided in different test cases:
in the first IT I have the cy.visit which visit the login page of my page filling it with user and password "the issue appears when I submit " I got a new URL generated and what I assumed is that it is not linking to the new url so the process stuck and cannot continue
so after that I got the error that the page cannot proceed, it stuck and get back to the login page and dont proceed with the other page generated automatically:
Well I am new in Cypress automation so I am not sure what is going on after I login on my page it get stuck in the process going back to the login page. So I am kind of sure it is not linking into the new URL that has the same domain so any person who has knowledge in Cypress can help me
Upvotes: 0
Views: 109
Reputation: 213
It is the way Cypress works to stop one test contaminating the next one, and giving you a false pass.
The way you need to handle is with a session command to keep your login credential renewed for each test.
This is the pattern:
describe('before logged in', () => {
it("Login into the system", function () {
cy.visit(Cypress.env("ur146b"));
//login
login.getUser().type(this.data.user);
login.getPass().type(this.data.pass);
login.getLogin().click();
cy.wait(1000);
});
})
describe('when logged in', () => {
// now make such the login is renewed for each test
beforeEach(() => {
cy.session('login', () => {
cy.visit(Cypress.env("ur146b"));
//login
login.getUser().type(this.data.user);
login.getPass().type(this.data.pass);
login.getLogin().click();
})
})
it("Menu - full quote - get client", function () {
cy.visit('/homepage');
menu.getPolicy().click();
menu.getQuote().click();
menu.getClient().click();
cy.wait(1000);
});
it("fill client and address info", function () {
cy.visit('/homepage');
...
});
})
Read the complete details documentation page
Sorry I missed one step - it is mandatory to use cy.visit()
in each test block after adding cy.session()
to the login.
Otherwise you get the "blank page" problem you mention.
Ref session
Because the page is cleared at the beginning of each test by default,
cy.visit()
must be explicitly called at the beginning of each test.
Upvotes: 3
Reputation: 1
enter image description here I make the changes on my code also I added on cypress.config :experimentalSessionAndOrigin: true
enter image description here I did my research and I got that the page is in blank and not showing the after login page
Upvotes: 0