Webdriver - How to check if browser still exists or still open?

0
0

I want to check if browser still exists and if it isn’t then i want to open a new browser!
Is there a api available in webdriver to check if the browser still exists?

  • You must to post comments
0
0

After calling driver.close() the value of driver is set to

FirefoxDriver: firefox on WINDOWS(4b4ffb1e-7c02-4d9c-b37b-310c771492ac)

But if you call driver.quit() then it sets the value of driver to

FirefoxDriver: firefox on WINDOWS (null)

So if you’re checking the browser window after calling driver.quit() then you will be able to know by below implementation.

WebDriver driver = new FirefoxDriver();
driver
.get("http://www.google.com");
driver
.quit();
if(driver.toString().contains("null"))
{
System.out.print("All Browser windows are closed ");
}
else
{
//open a new Browser
}
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website