Get Started With Non-Maven Selenium Project – Java – Eclipse

Introduction

A beginner should always start from scratch to build concepts block by block instead of jumping to advanced blocks. Keeping that in mind, I will share details on a get started non-maven Selenium Java project from scratch in Eclipse IDE. You can clone from my GIT repo as well.

Prerequisites

Must download and install Eclipse IDE

Java 8 should be installed on your system

Setup project step by step

Launch Eclipse

Open the Eclipse IDE. Make sure you have installed it and have created a workspace.

Create a Java Project

Navigate as File -> New -> Java Project

You may not get to create a Java project option directly. In that case, you can navigate as File -> New -> Others

Type “Java project” in the Search box and select from the result and click on “Next”.

Enter a project name and select JRE version

Give a meaningful project name and proper version of JRE. It will be good to get started with Java 8 version. You can also change the project default location. By default, the new project is created within the workspace. Click on “Finish”.

You will see a project created in the Package Explorer with the name entered by in above step.

Download Selenium WebDriver JAR file

You can download Selenium WebDriver JAR file from Selenium official website. At the time of writing this post, Selenium 4 version is going to be released but it is still in Alpha versions. If you click on “Download” ( Highlighted in yellow), it will download a stable version i.e. 1.141.59 but if you click on “Alpha” version it will download the latest alpha version i.e. 4.0.0-alpha-6. This may not be the same when you are referring to this post. Anyway I will keep updating with the latest update as well.

When you click on “Download”, a zip file will be downloaded. Unzip it and you will find a .jar file inside.

Add jar file to your project classpath

It will be good if you can create a folder and put downloaded jar file inside. Do right click on Project -> New -> Folder -> Enter folder name.

You must need to add jar file to the project build path to use Selenium commands. Perform below steps:

Right-click on jar file -> Build Path -> Add to Build Path

You should see a new item named “Referenced Libraries” within project with jar file.

Create a simple Selenium script

We will launch a chrome browser and load Google URL to it.

Right click on “src” -> New -> Class

Give package name (Optional) and class name.

I have explained launching a browser in detail here. If you face any issue feel free to email me or comment below.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyLearning

Find all Selenium related posts here, all API manual and automation related posts here, and find frequently asked Java Programs here.

Many other topics you can navigate through the menu.

5 thoughts on “Get Started With Non-Maven Selenium Project – Java – Eclipse”

Leave a Reply

Your email address will not be published. Required fields are marked *