Skip to content
Related Articles

Related Articles

How to Open Chrome Browser Using Selenium in Java?

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 20 Feb, 2022

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.


  • Eclipse IDE: Before downloading also make sure that your device has Java JDK. If you don’t have, install Java refer to this: How to Download and Install Java for 64 bit machine?. And install Eclipse IDE by referring to this article Eclipse IDE for Java Developers. 
  • Selenium: Download the Selenium latest stable version here
  • Web Driver: Web drivers is a package to interact with a web browser. It interacts with the web browser or a remote web server through a wire protocol which is common to all. Download Chrome Driver according to your Chrome Version here

Step by Step Implementation

Step 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”


import org.openqa.selenium.WebDriver;
public class GFG_Chrome {
    public static void main(String args[])
        // Instantiate a ChromeDriver class.
        WebDriver driver = new ChromeDriver();
        // Maximize the browser
        // Launch Website

Studying the code

The above script is for opening Google Chrome Browser and navigating to geeksforgeeks website. So let’s see how it works:

  1. Set a system property “” to the path of your ChromeDriver.exe file and instantiate a ChromeDriver class: System.setProperty(“”,”chromedriver location”); 
  2. Maximize the window: driver.manage().window().maximize();  
  3. To open the URL: driver.get(“URL link”)

Refer this video if any doubts

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!