You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JavaScript closes the window using the close() call.
I'm trying to determine the moment when a window is closed. page.is_closed() doesn't work, it shows False both before and after the window is closed.
I found a way to determine this using the following code:
with new_page.expect_event("close") as event_info:
pass
This code snippet waits for the window to close on its own, but during execution, a message is displayed on the screen:
Future exception was never retrieved
future: <Future finished exception=Error('Target page, context or browser has been closed')>
playwright._impl._api_types.Error: Target page, context or browser has been closed
What is the correct way to track window closing? How can I avoid the error messages in my code?