Why does browser closes automatically when latest version of WebDriverManager (5 onward) is used, is its new feature?


I recently created a new Selenium Maven project using the latest version(5.2.1) of WebDriverManager but I found that without using driver.quit() or driver.close() method, the browser closed automatically after test execution, is it a new feature of WebDriverManager (5 onward)?


As explained in the WebDriverManager doc, when you use the method create() for building WebDriver objects, WebDriverManager includes a shutdown hook that watches these objects correctly released before shutting down the JVM. If you want to avoid this behavior, you can use the method avoidShutdownHook(), for instance as follows:

WebDriver driver = WebDriverManager.chromedriver().avoidShutdownHook().create();

Answered By – Boni García

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published