I need to handle the case where my page may display a popup dialog at the load stage, or it may not appear. Clicking anywhere will remove it and I'm not interested in testing this dialog, but it blocks the page I need to access so it must be removed
This is the code that will get the dialog when it appears
cy.get('.wps_popup')
.find('[data-wps-popup-close]')
.click()
but I cannot put that at the top of the test, because this element might not appear.
How do I handle a conditional element - do I need to intercept
DOM changes and put that code in the event listener?