Last Updated : 23 Jul, 2025
Selenium is an open-source popular web-based automation tool. The major advantage of using selenium is, it supports all browsers like Google Chrome, Microsoft Edge, Mozilla Firefox, and Safari, works on all major OS, and its scripts are written in various languages i.e Java, Python, JavaScript, C#, etc. We will be working with Java. In this article, let us consider a test case in which we will try to automate the following scenarios in the Google Chrome browser.
For invoking the chrome browser, we need the Eclipse IDE, Selenium Grid(version 4), and Chrome web Driver.
InstallationStep 1:
Open the Eclipse IDE and create a new Java project. Right-click on the "src" folder and create a new Class File from New > Class. Give the Class name and click on the "Finish" button.
Step 2:
Add Selenium JAR file into the Java Project. Right-click on Class name and Select "Build Path" and select > configure build path
Then select Libraries > Classpath > and Click "Add External JAR's", now add the Selenium Jar and click "Apply and Finish"
JavaNote: It's always recommended to use Maven Project instead of downloading the JARs and configuring them manually. Maven Project can automatically install all the required JARs in form of Dependencies and configure them in build path. Later if any new version need to used, we can simply update the version in pom.xml and the new JARs will be installed and configured automatically. You can learn more here.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class GFG_Chrome {
public static void main(String args[])
{
System.setProperty(
"webdriver.chrome.driver",
"C:\\Users\\ADMIN\\Documents\\chromedriver.exe");
// Instantiate a ChromeDriver class.
WebDriver driver = new ChromeDriver();
// Maximize the browser
driver.manage().window().maximize();
// Launch Website
driver.get("https://www.geeksforgeeks.org/");
}
}
Studying the code
The above script is for opening Google Chrome Browser and navigating to geeksforgeeks website. So let’s see how it works:
Refer this video if any doubtsNote: Please note that with Selenium version 4.6.0, SeleniumManager has been introduced. It's still in beta version, but with SeleniumManager there is no need of external driver to launch Chrome, Edge or Firefox. External Driver always works for a specific version of the browser. As the browser version keeps updating automatically in most of the organisation, it was very difficult to keep updating the driver manually from time to time. With SeleniumManager that dependency has been removed. You can find more details on here.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4