I am working on a test automation framework for school. Everything works great except when I set a driver for a different version of the browser. I am unable to quit it.
Fe. I have Chrome 83 and I tried to run my tests with a driver for Chrome 84. Java gives the following error:
org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 84
I know that you are not allowed to use different versions of Chromedrivers with different of Chrome, but what if somebody did it and wants to replace the driver afterwards?
Apparently, driver = null when the incorrect version is loaded. I can not quit it in the code and it keeps running in the background. Therefore it is not possible to replace or remove the driver in the project. I just want to find a way to programmatically quit the driver whenever the 'SessionNotCreatedException' is thrown instead of force-quitting it in Task Manager.
@BeforeEach
public void beforeSuite() throws MalformedURLException, IOException {
String browser = configProperties.getProperty("browser");
switch(browser.toLowerCase()) {
case "chrome":
System.setProperty("webdriver.chrome.driver", configProperties.getProperty("chromepath"));
driver = new ChromeDriver();
break;
}
@AfterEach
public void afterSuite() {
driver.quit();
}