The question is as simple as that. In Cypress, how can I access a new window that opens up when running the test.
Steps to recreate :
- Run the test. After some action, new window pops up (the url is dynamic in nature).
- Fill in the fields in the new window, and click a few buttons.
- After required actions are completed in the new Window, close the new window and move back to the main window.
- Continue execution with the main window.
Point of interest: the focus should be
main window -> new window -> main window
I have read few things that relate to use of iframe
and confirmation box
, but here its none of those. Relates to accessing a whole new window. Something like Window Handlers
in Selenium. Unfortunately could not find anything related to it.
Accessing new windows via Cypress is not possible in its current version.
However, there are many ways this functionality can be tested in Cypress now. You can split up your tests into separate pieces and still have confidence that your application is covered.
Fullly working test example can be found here.
I am not cypress expert, just started using it few days ago, but I figured out this kind solution for stateful application with dynamic link:
Is there any better way to do this?