Selenium Automation Testing - How to launch a browser
Selenium Tutorial for Beginners

Selenium Automation Testing | How to Launch a Browser

What do you think should be the first script in our journey to learn Selenium Automation testing? Yeah! For any web-based testing, first & foremost you need to launch a browser and open the application URL. How? Let’s learn how to launch Chrome browser using Selenium Webdriver!

Selenium Automation Testing | Pre-requisites

Download Chrome Driver

To run Selenium Webdriver scripts in different browsers, first we need to download the browser-specific driver, i.e. ChromeDriver used by Selenium Webdriver to control chrome browser. ChromeDriver is supported by the Chromium team, ChromeDriver is a standalone server which implements WebDriver’s wire protocol for Chromium.

Click here to download the latest version of ChromeDriver server for Selenium Webdriver (under Third Party Browser Drivers NOT DEVELOPED by seleniumhq heading)

Download ChromeDriver for Selenium Automation Testing

Note: Choose the chromedriver based on your working environment. For Windows, use (can be used for 64-bit machine as well). Save the driver zip file & unzip it in your desired location to get chromedrive.exe file

The Java code to launch Chrome browser

Now that we have downloaded all the pre-requisites for Selenium Automation Testing, let’s see at the Java code to open or launch Chrome browser using Selenium Webdriver.

package learnautomation;


public class LaunchChrome {

      public static void main(String[] args) {

            System.setProperty(“”, “C:\\Users\\deepansagarwal\\Downloads\\Selenium\\chromedriver.exe”);

            ChromeDriver driver=new ChromeDriver();


            System.out.println(“Test script executed successfully.”);



Import ChromeDriver class

To use all the in-built functionality of ChromeDriver, i.e. the pre-defined functions – we need to first import the class to our Java code.


The path to the driver executable must be set by the system property

For Selenium to know the location of Chrome driver, we need to set it via the as below,


Note: To set variable in Java we use the ‘setProperty’ method of System class!

Driver declaration and instantiation

To use Chromedriver first we need to create an object of type Chromedriver and then instantiate it as below,

ChromeDriver driver=new ChromeDriver();

Now the ‘driver’ object has been created which can be used to call browser actions.

Launch chrome and open application URL

To launch Chrome, we will use the ‘get’ function using the ‘driver’ variable instantiated with ChromeDriver class, as below…


And there you go – once you execute the above code, Selenium Webdriver will launch the Chrome browser with URL as!

Happy start with Selenium Automation Testing!!

Looking for a Job Change in QA/Testing technology? Get Regular Job notifications @ WhatsApp!