I am using Cypress to automate this website https://admin.britex.pw/
The issue occurs when during automation after a few It blocks, on click of a link (anchor) tag, the website gets logged out. I cannot understand why this happens as if I browse the website manually, it works fine.
The issue occurs after this command in my code:
cy.get('table#table tbody tr').first().find('td').eq(2).find('a').click();
But this is not related to testIsolation:false as it is already false and It happens only after that click(). if I skip .click() from above command, it works fine.
Expected: I just want to click and interact and then perform actions.
describe('', () => {
before(() => {
Cypress.on('uncaught:exception', (err, runnable) => {
return false;
});
cy.clearCookies();
cy.clearLocalStorage();
cy.clearAllSessionStorage();
//cy.viewport(1920, 1080);
});
it('Visit Admin dashboard', () => {
cy.visit("https://admin.britex.pw", { failOnStatusCode: false });
cy.wait(3000);
});
it('Login as Admin', () => {
cy.loginAdmin('[email protected]', '12345678');
});
it('Selecting Teltik Test as Company', () => {
cy.get('.custom-select[name="company"]').select('1');
cy.wait(2000);
cy.get('.swal-button').click();
cy.wait(6300);
});
it('Selecting user to create a custom invoice', () => {
cy.get('.form-control#validationDefaultUsername')
.should('be.visible')
.clear()
.type('[email protected]');
cy.get('li>.searchEmail').click({ force: true });
cy.wait(3000);
cy.get('table#table tbody tr').first().invoke('text').then((value) => {
cy.log('Value in Second Column:', value);
// Now, re-select the first row and click the link without using alias
cy.get('table#table tbody tr').first().find('td').eq(2).find('a').click();
cy.wait(5000); // Add a delay
}).debug();
});
it('Selecting Billing tab and creating a custom invoice', () => {
cy.get('#billing-tab').click();
cy.wait(2000);
cy.get('#payment_type[name="payment_type"]').select('Custom Invoice');
cy.get('#invoice_type[name="invoice_type"]').select('Create New Invoice');
cy.get('#usage_type[name="type"]').select('One Time');
cy.get('.subscription_id').select(':nth-child(2)');
cy.get('#amount').type('100');
cy.get('#description').type('test');
cy.wait(1500);
cy.get('.btn.btn1.sendbtn2[type="submit"]').click();
cy.wait(2000);
});
});