SetUp Selenium WebDriver


This article is part of a series. You can find the full series here : Selenium Tutorial

This article will show you how to setup the WebDriver so that you can start writing tests. We will be using the Chrome Driver but the steps are the same for the rest of browsers as-well.

The pre conditions up to this point is that you have Java version installed. You can check by running into a terminal the below command:

Any version above 8 will be just fine for this tutorial.

Also you should have your favourite IDE, like Eclipse, InteliJ etc.

As this tutorial is with Java we will be using Maven for our project. The Selenium jars cab be added as a dependency from Maven repository

Before we start writing any code we also need to download and add to the project the browser driver.

What is this browser driver and why do we need it?

The browser specific driver (ChromeDriver, FireFoxDriver, EdgeDriver, etc) is a separate executable that we need on the project as this is being used by Selenium WebDriver API to send commands to the actual browser.

This driver (ChromeDriver in our example) expects that the actual browser (Chrome) is installed on the system.
You can download the ChromeDriver from here :WebDriver for Chrome Once downloaded, make a new folder on your project root called “drivers” and put the executable file there.

Setting up the WebDriver

First thing that we need to do in order to be able to execute Selenium scripts is to tell Selenium where he can find the browser specific driver. And we do this by setting a system property like below: