Environment Setup for Selenium WebDriver with Java

Selenium test automation tool is a library in various language bindings like Java, PHP, Javascript, C#, and Python.

In this tutorial, we will set up a project for Selenium with Java programming language.

Pre-requisite — 

  1. JDK and JRE installed. (Download and install JDK )
  2. JAVA_PATH set as an environment variable on your system
  3. Eclipse IDE or IntelliJ, or Visual Studio code
  4. MAVEN installed and setup on the system
  5. GIT installed and configured on the system
  6. TestNG plugin installed in your IDE

To install the TestNG plugin in Eclipse, follow the following steps –

  1. Navigate to Help >> Market Place
  2. Search for “TestNG” and select “TestNG for Eclipse”
  3. Click Install, accept the license
  4. Restart the Eclipse.

Maven project setup on Eclipse — 

  1. Open Eclipse, create a new project (File >> New)
  2. Select Maven project, click Next

3. Select “Create a simple project” and click Next.

4. Enter Group Id; this is your organization id. Example — “com.qatechhub”

5. Enter artefact Id; this is the name of your project. Example — “LearningSelenium”. Click Finish

6. Next step, right-click “JRE System Library” >> properties >> change “execution environment” to JDK 11 (or the latest version). Apply and close.






7. In pom.xml, copy and paste the below dependencies and save. This will download the libraries and dependencies in your project.

<dependencies><!--

https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --><dependency>

<groupId>org.seleniumhq.selenium</groupId><artifactId>selenium-java</artifactId><version>4.1.1</version>

</dependency>

<!-- https://mvnrepository.com/artifact/org.testng/testng --><dependency>

<groupId>org.testng</groupId>

<artifactId>testng</artifactId><version>7.5</version><scope>test</scope>

</dependency></dependencies>

This complete the project setup. We have created a MAVEN project, added all the dependencies required into this project.

If you have any question or query. Feel free to reach out to saurabh@qatechhub.com

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra: