I have encountered a challenge where I need to execute some tasks before the close button on Google Chrome browser is clicked and the window is closed.
This involves logging out of the website among other things. Completely clearing cookies is not an option in this case. Unfortunately, I haven't been able to find any examples that allow me to set up something similar to a shutdown hook like in Java.
Is there a way in Selenium to override the default close functionality so I can carry out the necessary tasks before exiting the browser when the close button is clicked or the window is closed manually?
To sum it up:
Due to specific design constraints, performing cleanup when a test exits is impossible. Is there a way to intercept the close button click (manual click)?