I'm using C# / Selenium 3 and the Microsoft Chromium Edge Webdriver to scrape a web page and then deliver data to another application. I need to check if the user has closed the web browser. Is there a quick way of doing this? I came up with the code below but the problem is that if the web browser is closed then _webDriver.CurrentWindowHandle takes 4 seconds or more before it throws an exception.
public bool IsOpen
{
get
{
if (!this._isDisposed)
{
try
{
_ = this._webDriver.CurrentWindowHandle;
return true;
}
catch
{
// ignore.
}
}
return false;
}
}