How can I use Selenium ChromeDriver on Windows OS?

Can anyone please tell me how can I use Selenium ChromeDriver on Windows OS.

1 Like

ChromeDriver is used along with Selenium to automate tests on the Chrome browser. Using Selenium ChromeDriver, you can communicate with Chrome browser to perform different operations like navigation from one web page to another web page, users can provide input on the web pages, javascript execution and many more operations.

In this article, I will show you how to use ChromeDriver to perform Selenium test automation. I’ll go into details about the ChromeDriver, starting from download, installation and to use it on Windows and Mac.

What Is ChromeDriver In Selenium?

To perform automated browser testing on Chrome browser, ChromeDriver class, a standalone executable, is used by Selenium WebDriver to create communication of our test script with the Chrome browsers. You can create a WebDriver object for Chrome like below:

 //Creating WebDriver object for Chrome browser
    WebDriver driver =  new ChromeDriver();

Selenium WebDriver helps our test script capabilities or power to communicate with the browser. ChromeDriver class extends WebDriver interface. It is an implementation of WebDriver interface which is used to control the Chrome browser running and operations on the local machine.

With the help of Selenium ChromeDriver class, we can easily interact with Chrome browser and perform automation testing of web applications on chrome browser.

This is implementation for Selenium ChromeDriver class

org.openqa.selenium.chrome.ChromeDriver

What Are The Requirements For Selenium ChromeDriver?

Before starting to explore Selenium ChromeDriver, there are few prerequisites which should be available on your system.

  1. Java/ JDK/JRE: In this guide, I’ll perform automation testing in Selenium with Java, so in order to run the tests I’d need to have Java/JDK/JRE installed in my system.You can download and install it from the official website for Java. https://www.java.com/en/download/I have used Java 8, JRE-1.8 for the Selenium test automation script execution.
  2. Eclipse IDE: To write a test automation script with selenium, you’d require an editor. In this case, I have used eclipse IDE. It can be downloaded from the official website of Eclipse. https://www.eclipse.org/downloads/You can use the same editor or you can use other editors as well.
  3. Selenium: To write selenium automation test scripts, you’d require Selenium to be installed in your system. You can download it from the official website of selenium. https://selenium.dev/downloads/In this article I have used selenium version 3.141.59, which is the latest stable version of selenium.
  4. Chrome Browser: Since we’d be performing Selenium test automation on chrome browser, it is required that our system should have chrome browser installed. It can be downloaded from https://www.google.com/intl/en_sg/chrome/I have used google chrome Version 78.0.3904.108 for the Selenium automation script.

To download Selenium ChromeDriver, go to the official website of Selenium.

How To Use Selenium ChromeDriver On Windows?

Now that I have downloaded ChromeDriver and have installed other prerequisites applications as well in the system, I’ll use ChromeDriver and perform Selenium test automation scripts for the login test case on LambdaTest website.

For Windows, there are two different methods for Selenium test automation with ChromeDriver.

a) By using setProperty()

Using the setProperty() method from system class, I’ll provide the path of ChromeDriver from where the Selenium WebDriver can access it for Selenium test automation.

You can see the syntax for, how to set the location for the ChromeDriver.exe below:

System.setProperty("WebDriver.chrome.driver", "\\path to ChromeDriver\\ChromeDriver.exe");

b) By adding path in Environment Variable

In the above part I showed the execution of the Selenium test automation script using ChromeDriver, by providing a path of ChromeDriver in the test script itself.

There is another way as well, where I can set the path of ChromeDriver.exe in the system environment variable itself so that i don’t need to set the path in selenium test automation script explicitly.

Read here to perform Automation Testing Using Selenium ChromeDriver.