0

I access Websites in a loop via selenium Java based. Some of the sites crash imediately so that i get the error

[1618982990.911][WARNING]: Timed out connecting to Chrome, retrying...

after a short time.

So this is not a selenium issue i assume, since even chrome crashes if i visit the site manually because of js errors, saying unresonsive Website

My problem is, that every time a site crashes, chromedriver and a chrome instance will stay alive so that i have high CPU usage after a short time.

Can i tell selenium to quit the instance if it is frozen? But i dont know how this should be possible if it does not get answer from chrome anymore?

Thankful for any solution or idea

Roo
  • 13
  • 3

2 Answers2

0

Sometimes with some Windows version driver.quit() will not kill the chrome process which I have come across. So at the end of the script you can kill the chrome processes if exists using java code, if the driver.quit doesn't work.

Please refer stackoverflow link which has the code to kill the process if exists in Java and pass the chrome process to it.

0

i found a workaround for anyone who would be interested. First setting up a pageLoadTimeout, after that force any chrome instance to be killed if an Exception is being thrown.

 try{
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
//some excecution code....
}

catch (Exception e) {
        System.out.println("Error. Closing");
        driver.quit();
        Runtime.getRuntime().exec("taskkill /F /IM chrome.exe");}
Roo
  • 13
  • 3