Reputation: 1203
I have written codes to click on hyperlink then check the new window URL.
cy.get('a[href*="newlink"]').eq(0).click()
cy.url().should('equal', 'https://www.google.com')
how do i close this window / or not close AND back to the original main test window?
Upvotes: 3
Views: 16694
Reputation: 357
here's a solution i use for swapping between popup windows: https://github.com/jakedowns/CypressHelpers
it would need some tweaking to work directly with .click but it does enable cy.openWindow and a new cy.switchWindow / cy.closeWindow
under the hood it uses an undocumented
cy.state('document')
and cy.state('window')
method for context-switching
Upvotes: 4
Reputation: 3226
cy.go(direction, options)
See the documentation for examples
This works for the history in the same tab. Cypress does not support multiple tabs.
Upvotes: 1