I am having a problem with geckodriver (FF) in java-selenium. I am running multiple test scenarios via TEST-NG parallel execution (6+ threads).
Sometimes happens that at the start (opening new browser) I get unreachableBrowserException. So i try-catch it, waited 100ms and try to create it again. it works, but it keeps the first failed browser opened, with a blank page.
Problem is that the first window got opened BEFORE it got initialized as a driver, so it cannot be closed by driver.close() or something (it is null). So I have to close them manually.
So, my question is, has anyone encountered such behaviour? How can i close such browsers, without influencing the other threads?
while(true) {
try {
setDriver(DriverFactory.createInstance(getBrowserInstance()));
break;
} catch (UnreachableBrowserException e) {
try {
Thread.sleep(100);
log.info("UnreachableBrowserException! Needed to wait for 100ms ");
removeDriver();
counter++;
} catch (Exception e1) {
log.info("Thread could not wait!");
e1.printStackTrace();
}
}
if(counter>100){
log.info("Was not able to create a browser session!");
break;
}
}
and the part of .createInstance :
final ProfilesIni profilesIni = new ProfilesIni();
System.setProperty("webdriver.gecko.driver", "drivers/geckodriver.exe");
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE,"false");
firefoxProfile = new FirefoxProfile();
firefoxProfile.setAcceptUntrustedCertificates(true);
firefoxProfile.setAssumeUntrustedCertificateIssuer(false);
firefoxProfile.setPreference("app.update.auto", false);
firefoxProfile.setPreference("app.update.enabled", false);
firefoxProfile = profilesIni.getProfile("selenium_profile");
capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
return new FirefoxDriver(capabilities); //Here it throws the exception.
Selenium/Java/geckodriver versions are most recent. FF version is unfortunately 44.02 (cannot get newer). I would be grateful for any tips/hints.
Kind regards, Martin