In earlier days of web automation using Selenium, we used to start a driver session with help of many intermediate steps and third-party dependencies. We used System.setProperty to set the driver executable path prior to instantiating the session and used this method for many years as a traditional way to start the session, in this method we have to download the driver executable each time and set the path whenever the new browser version released. Following is the syntax we used,
System.setProperty("webdriver.chrome.driver","path to chromedriver.exe"); //in case of chrome browser. WebDriver driver = new ChromeDriver();
Later, the automation engineers replaced System.setProperty with WebDriverManager dependency. The WebDriverManager dependency introduced by bonigarcia and it is a good approach to avoid setting up the driver executable path, using WebDriverManager dependency we can start the driver session using the installed browsers in the system and also we can specify the required browser version to execute, but the only thing we have to add the WebDriverManager dependency into our automation project. Following is the syntax we used to instantiate a chrome driver session using WebDriverManager,
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
Selenium, now with batteries included. Yes, the Selenium project wants to improve the user experience, and one of the first steps is to help all users to simplify how they set up their environment. Configuring browser drivers has been for many years a task that users need to perform in order to have a working environment to run Selenium. As browser release cycles got shorter and the new version releases every 4-6 weeks, the task of keeping the browser driver in sync with the browser version is not that easy anymore.
Selenium Manager is a new tool that helps to get a working environment to run Selenium out of the box. Selenium announced, the Beta 1 of Selenium Manager will configure the browser drivers for Chrome, Firefox, and Edge if they are not present on the PATH. It’s a built-in feature available in Selenium 4.6.0 version. The following are the benefits of using Selenium Manager:
- No need to setup any environment variables for binaries/executables.
- No need to use System.setProperty(“webdriver.chrome.driver”, “executable path of binary”).
- No need to use WebDriverManager.chromedriver().setup().
- Directly use: WebDriver driver = new ChromeDriver();
- This feature is available for Java, .NET, Python, Ruby, and JavaScript bindings as well as the Grid and Internet Explorer Driver.
The only prerequisite that needs to be added is the Selenium 4.6.0 dependency on your project, in this article I used Selenium 4.7.0 because it also supports IEDriver. If you are using Java Maven project, you can add the below dependency in the pom.xml file:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.7.0</version> </dependency>
Once you add the above dependency and complete the project refresh, you will able to see the selenium-manager library along with selenium-manager executable for different operating systems (macOS, Windows and Linux) in your Maven Dependencies section of the project as below,

Next, you can write the direct code to instantiate the driver session for your selected browsers. Following are the sample snippets to start the driver sessions and load applications in Chrome, Firefox and Edge browsers:
@Test public void TC001_testChrome() { WebDriver driver = new ChromeDriver(); driver.get("https://www.google.com/"); System.out.println(SeleniumManager.getInstance().getDriverPath("chromedriver")); }
@Test public void TC002_testFireFox() { WebDriver driver = new FirefoxDriver(); driver.get("https://www.google.com/"); System.out.println(SeleniumManager.getInstance().getDriverPath("geckodriver")); }
@Test public void TC003_testEdge() { WebDriver driver = new EdgeDriver(); driver.get("https://www.google.com/"); System.out.println(SeleniumManager.getInstance().getDriverPath("msedgedriver")); } @Test public void TC004_testIE() { WebDriver driver = new InternetExplorerDriver(); driver.get("https://www.google.com/"); System.out.println(SeleniumManager.getInstance().getDriverPath("IEDriverServer")); }
In the above code, we used getDriverPath method with different driver names; this method actually helps us to get the actual path of the driver executable located in the system.
Selenium Manager is still under development, features will be added and bugs fixed along with each release. Anyway, this is a good time for automation engineers can explore the opportunities of using Selenium Manager in the automation POC or automation frameworks.
make it perfect!
Leave a Reply