protected WebDriver maximize(WebDriver driver) {
   if (startMaximized) {
     try {
       if (isChrome()) {
         maximizeChromeBrowser(driver.manage().window());
       } else {
         driver.manage().window().maximize();
       }
     } catch (Exception cannotMaximize) {
       log.warning("Cannot maximize " + browser + ": " + cannotMaximize);
     }
   }
   return driver;
 }
 protected boolean isBrowserStillOpen(WebDriver webDriver) {
   try {
     webDriver.getTitle();
     return true;
   } catch (UnreachableBrowserException e) {
     log.log(FINE, "Browser is unreachable", e);
     return false;
   } catch (NoSuchWindowException e) {
     log.log(FINE, "Browser window is now found", e);
     return false;
   } catch (SessionNotFoundException e) {
     log.log(FINE, "Browser session is not found", e);
     return false;
   }
 }
 @Override
 public void run() {
   try {
     log.info("Trying to close the browser " + webdriver + " ...");
     webdriver.quit();
   } catch (UnreachableBrowserException e) {
     // It happens for Firefox. It's ok: browser is already closed.
     log.log(FINE, "Browser is unreachable", e);
   } catch (WebDriverException cannotCloseBrowser) {
     log.severe(
         "Cannot close browser normally: "
             + Cleanup.of.webdriverExceptionMessage(cannotCloseBrowser));
   } finally {
     killBrowser(webdriver);
   }
 }
 public void clearBrowserCache() {
   WebDriver webdriver = THREAD_WEB_DRIVER.get(currentThread().getId());
   if (webdriver != null) {
     webdriver.manage().deleteAllCookies();
   }
 }