Don't have Telegram yet? Try it now!
https://watirmelon.blog/2016/07/05/handling-javascript-alerts-when-leaving-a-page-with-webdriver/
Handling JavaScript alerts when leaving a page with WebDriver