Selenium 4.6.0: The Selenium Manager

Selenium 4.6.0: The Selenium Manager

Table of contents

No heading

No headings in the article.

I have started learning automation using Selenium WebDriver by setting the path of the browser driver executable file using System.setProperty().

Because it is a tedious task, moved to a third-party library called WebDriverManager. It has really helped reduced the effort of setting up drivers for browsers in Selenium WebDriver automation.

Now the Selenium Community, has itself come up with new in-built feature called Selenium Manager in Selenium 4.6.0 version. Though it is beta version currently, the community going to release stable version for sure.

The Selenium community says, "Selenium Manager is a new tool that helps to get a working environment to run Selenium out of the box. Beta 1 of Selenium Manager will configure the browser drivers for Chrome, Firefox, and Edge if they are not present on the PATH"

We have to make sure that the browsers we want execute selenium tests, have installed already. Selenium Manager takes care of respective browser drivers.

Adding this maven dependency in pom.xml file.

<dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.6.0</version>
 </dependency>

Lets launch all three browsers using Selenium Manager.

package PageTests;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class SeleniumManagerTests {

    @Test
    public void testLaunchingChromeBrowser_001() throws InterruptedException {
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.selenium.dev/downloads/");
        driver.manage().window().maximize();
        Thread.sleep(2000);
        System.out.println(driver.getTitle());
        driver.quit();
    }

    @Test
    public void testLaunchingFirefoxBrowser_002() throws InterruptedException {
        WebDriver driver = new FirefoxDriver();
        driver.get("https://www.selenium.dev/downloads/");
        driver.manage().window().maximize();
        Thread.sleep(2000);
        System.out.println(driver.getCurrentUrl());
        driver.quit();
    }

    @Test
    public void testLaunchingEdgeBrowser_003() throws InterruptedException {
        WebDriver driver = new EdgeDriver();
        driver.get("https://www.selenium.dev/downloads/");
        driver.manage().window().maximize();
        Thread.sleep(2000);
        System.out.println(driver.getPageSource());
        driver.quit();
    }
}

From the above code snippet, its just one-liner to setup the browser to be launched in our all new Selenium Manager.

Thanks to our Selenium Community, for all this efforts. Thank you for reading.

Did you find this article valuable?

Support Brahma Rao Kothapalli by becoming a sponsor. Any amount is appreciated!