Setting Up Chrome Driver

In this tutorial, we will earn how to set up a chrome driver with selenium.

 

First, check the version of the chrome browser

 

version

Now Go to the URL and download

https://chromedriver.chromium.org/downloads

dev_ver

Now click on the version you have.

A new tab will be open.

Now click on the 

Chromedriver_win32.zip

down

It will work for both windows 64 and 32 bit

As the download completes, extracts the files from the zip files and save them in the folder. We will use the path for the extracted files later.

As the driver is extracted create a new Package in test java

Project > src > test > java

Right click on the java

Take the mouse to New and click on the package

After clicking on the Package, add the Package name myTestProject and press enter

Now the package is created.

test

Now create a new class in the package by right-clicking on the Package name.

cls

Add Class name main

mai

In Java main class and method is needed to execute the code.

Class is created now we will create the method in the class main

 

public static void main (String [] args){

}

cl

 

Now we will add the path for the driver we downloaded.

path

Here all the code required to execute the code and open the required URL as below

 

package myTestProject;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

 

public class main  {

    public static void main (String [] args){

        System.setProperty(“webdriver.chrome.driver”, “D:\\chrome\\chromedriver_win32\\chromedriver.exe”);

        

        //now create the web driver object

        WebDriver driver = new ChromeDriver();

        

        //open URL

        driver.get(“https://www.google.com/”);

    }

}

cod

Now run the code as mentioned in the screenshot below. Your code will be executed.

run

Now in the next tutorial, we will learn the element path and locations to access the web element