Due to Cypress' inability to access browser tab, I have to use one of recommended bypasses: my test changes target attribute of the link from target: "_blank" to target: "_self". After clicking the link the target page is open in the same tab as expected, but the test freezes without any notification and stops working. The browser window can't be closed by clicking "X" button. The test can be interrupted with Stop button of the Test runner only. Is there any solution for this issue?
I need to add something important to this question: it looks like the reason is that after the page is open and verified by the test, the next test following it tries to navigate back to the page from where the previous test was redirected to the target page and this cy.visit() command freezes this test. Visually there is no any navigation occurred.
Actually I have 2 tests and each of them works fine (e.g. if you use "only" flag for any of them), but if you run the both does not matter in which order, the second test freezes:
it('The first test', () => {
cy.visit(startPageUrl);
// Redirect to page 1
cy.get(linkSelector1).invoke('removeAttr', 'target').click()
cy.get(selectorOfTheElementToBeAssertedOnThePage1).should('be.visible');
})
it('The second test', () => {
cy.visit(startPageUrl); // The test freezes here
// Redirect to page 2
cy.get(linkSelector1).invoke('removeAttr', 'target').click()
cy.get(selectorOfTheElementToBeAssertedOnThePage2).should('be.visible');
})