jakedowns/CypressHelpers

route and wait does not seem to work for new tabs

Opened this issue · 3 comments

first of all, thanks a lot for this wonderful piece of code.

I have used it my project and it works like charm.
I'd like to share some of my observations that I think can help.

  • I am using wait and route in my test cases. And I observed that these 'Cypress' methods do not work on tabs. For example when using route I am not able to intercept the XHR requests made from the tab.

  • Also I noticed that visit cease to work correctly on original window after we close the tab.

Can you please share your thoughts? Or if this is something that you already aware of?

Kindly let me know if I need to provide more information or if I can be of any help.

Thanks again !

Note: We are on Cypress 4.x and that's why we are still using route and did not switch yet to intercept.

Can someone please help here? Thank you.

Great piece of code, thank you very much for this module.

I am trying to use cy.on('window:confirm', () => true) when a popup window appears on newly opened tab but it doesn't work. Any idea why?

first of all, thanks a lot for this wonderful piece of code.

I have used it my project and it works like charm. I'd like to share some of my observations that I think can help.

  • I am using wait and route in my test cases. And I observed that these 'Cypress' methods do not work on tabs. For example when using route I am not able to intercept the XHR requests made from the tab.
  • Also I noticed that visit cease to work correctly on original window after we close the tab.

Can you please share your thoughts? Or if this is something that you already aware of?

Kindly let me know if I need to provide more information or if I can be of any help.

Thanks again !

Note: We are on Cypress 4.x and that's why we are still using route and did not switch yet to intercept.

Hey! glad to hear you were able to get some use out of these helpers.

I only tested these on Cypress v5+, and (they're up to 11 now, with 12 coming soon? wow!)

i never tested with the wait or route/intercept commands,
my guess tho, would be in a similar way to how i've overwritten the built-in cy.visit to accept an extra tab_name parameter, you could overwrite those other two commands in a similar fashion, to specify which tab should be targeted for those contexts. Tho i would've imagined just doing a switchTab and then calling them would've applied the wait/route/intercept to the correct context

i can maybe look into this further if it'd still be helpful to you or anyone else

as for "returning" to the root window, if you supplied a tab_name to cy.visit, you should be able to switch back after closing the other tab by using switchToTab('whatever you named your root') it's name is "root" by default, so switchToTab('root') if you never gave the visit a tab_name