Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

How To Launch Chrome Browser In Selenium WebDriver – Java

Posted on 02/19/2025 By admin

Selenium automates a browser. There are multiple browsers supported by Selenium WebDriver. Major browsers are – Google Chrome, Mozilla Firefox, Microsoft Internet Explorer, Microsoft Edge, Opera, and Safari. In this post, we will learn to “Launch a chrome browser in Selenium WebDriver 3 and 4“.

First, check if you have a Chrome browser installed in your system. If it is installed then jump to the next step otherwise install the Chrome browser from here. Installation is just like any other software installation. Click on the installation file and Next Next Next……

Since we will use Java binding of Selenium WebDriver to launch a Chrome browser, please set up a Selenium Java project as discussed here.

Selenium WebDriver provides corresponding classes for browsers. For example:- For Chrome -> ChromeDriver, For Firefox -> FirefoxDriver. To launch any browser through Selenium WebDriver we just need to create an object of their corresponding class.

package BasicSeleniumConcepts;

import org.openqa.selenium.chrome.ChromeDriver;

public class LaunchChromeBrowser {
        
        public static void main(String[] args) {
                
                ChromeDriver firefoxDriver = new ChromeDriver();
                firefoxDriver.get("https://www.google.com/");
        }

}

We were expecting that a chrome browser should have launched but we got an exception IllegalStateException and states that “The path to the driver executable must be set by the webdriver.chrome.driver system property“.

Selenium WebDriver can not communicate with a browser directly. We need an intimidatory executable agent between Selenium WebDriver and the actual browser. These intimidatory are provided by third parties. For chrome, we need a chromedriver as an interface between Selenium WebDriver and a real chrome browser.

There is a critical part that for each version of the Chrome browser, you may have different chromedriver executable version. Many times you may face issues when Selenium will not be able to create a WebDriver session and maximum time reason is an incompatibility of Chrome browser version and chromedriver version.

I will advise you to download the latest chrome browser and chromedriver always. If you are using an older version of Chrome browser due to some restrictions always read release notes to know which chromedriver version will support your current version of chrome browser.

I have below version of chrome browser installed on my system.

Let’s find a compatible version of chromedriver for my installed version of chrome. Remember this is just for reference. These versions will be changed with time. So just to follow the above process and download the correct version of chromedriver.

Just click on the link and select as per your operating system and click on that. It will start downloading. It is a zipped file that you need to unzip. After unzip you will get a chromedriver.exe file as exe is an extension of executable file on Windows. For Mac and Linux there will be no extension as they follow permission-based capability to identify an executable file.

For Windows, chromedriver_win32 works for both 32 and 64 bit systems.

Note:- You can rename this file whatever you want. There are no restrictions that you can not change its name. Many beginners get confuse on this. You just need to use the changed name in your program.

Before launching a Chrome browser you need to let WebDriver know explicitly the location of chromedriver executable file. As of now, we will add the path of chromedriver as a system property. There are some other ways as well which we will see later. Any System property is set as a key-value pair and to set path of chromedriver, selenium WebDriver has a key as “webdriver.chrome.driver”. Remember you can not change the key to some other name.

Remember we need to set a path of chromedriver with the extension of it if available. It is needed for Windows but for Linux and Mac, you need to give it executable permission.

package BasicSeleniumConcepts;

import org.openqa.selenium.chrome.ChromeDriver;

public class LaunchChromeBrowser {
        
        public static void main(String[] args) {
                
                System.setProperty("webdriver.chrome.driver", "C:\\Users\\amomahaj\\Downloads\\chromedriver_win32 (2)\\chromedriver.exe");
                ChromeDriver firefoxDriver = new ChromeDriver();
                firefoxDriver.get("https://www.google.com/");
        }

}

Now you will see a chrome browser will be launched and Google homepage will be loaded.

Do not worry about seeing these red lines. They are just logs. You can ignore it as of now. It has some important messages which will see later.

You can download/clone the above sample project from here.

If you have any doubt, feel free to comment below.If you like my posts, please like, comment, share and subscribe.#ThanksForReading

#HappyLearning

Uncategorized

Post navigation

Previous Post: Facts, Misconception & Myths About Selenium WebDriver
Next Post: #2. OAuth 2.0 Flow – Authorization Grants And Their Types

Related Posts

March 4, 2019 – Make Selenium Easy Uncategorized
November 3, 2018 – Make Selenium Easy Uncategorized
Postman Tutorial Part 2 – Installation of Postman Tool – Chrome App, Native App and Web app Uncategorized
Handling ElementNotVisibleException And Element Is Not Clickable Exception In Selenium Uncategorized
Selenium interview expereince Uncategorized
TestNG Tutorials 2: Installation Of TestNG In Eclipse ==> Download And Add To Build Path Way | Make Selenium Easy Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark