Beginners guide -Test automation environment setup

IntelliJ — Java, Selenium, Maven, Cucumber

In this guide, I'm going to walk you through the test automation project environment setup using IntelliJ(IDE), Maven, java, Selenium, Cucumber stack.

By following this guide, you will be able to set up a project environment and run simple test automation.

What is Intellij?

Computer Software

IntelliJ IDEA is an Integrated Development Environment (IDE) written in Java for developing computer software. Below I’m explaining just the steps to follow to make a new project in IntelliJ beginning from installing required software packages.

Before proceeding check whether you are having java on your computer or not. Go to the command prompt and type,

java -version

If it is already installed will display the version as below.

Or else you have to install java first.

  1. Install JAVA

Here I’m using the Windows platform. So I’m downloading java for windows.

  • Java for Windows /Linux

2. Install IntelliJ IDEA community — for windows

Here I have selected the community edition since it is free. If you want, you can select the ultimate over the community edition. There are many features included in ultimate other than the community edition.

3. MAVEN DownLoad

Apache Maven is a software project management and comprehension tool based on a Project Object Model (POM) concept. Maven can

  • manage a project’s build
  • reporting and documentation from a central piece of information.

4. Set system path variable

After downloading and setting up the Java, IntelliJ, and Maven, you must set the system paths.

Right-click on MyComputer → Go to properties

  • Make new System variables for Java and Maven

Ex :

JAVA_HOME -C:\Program Files\Java\jdk-11.0.2\bin

MAVEN_HOME -C:\Program Files\apache-maven-3.8.1-bin\apache-maven-3.8.1

Verify you have install Maven correctly.

  • Type mvn -version in cmd prompt. If it is ready to use will indicate as below with the version you have.

If not you will get the below messages

Two most common error messages

  • ‘mvn’ is not recognized as an internal or external command

Solution: Set the %MAVEN_HOME%\bin is added to the PATH system variable.

*JAVA_HOME should point to a JDK(Development kit), not a JRE(Java Run time Environment)

Solution: Verify JDK is installed and the JAVA_HOME system variable is configured.

ex :

5.Create New Project n IntelliJ IDEA and add plugins cucumber and gherkin.

Open IntelliJ IDEA

Add pluggings to the project

  • Cucumber for Java
  • Gherkin Plugin

a. Go to File → Settings → Plugins → Marketplace

To install ‘Cucumber for Java’ first you have to install the Gherkin plugin. Then install Cucumber for plugging.


b. Add the Gherkin plugin and then add the Cucumber plugin.

c. After installing you can check whether the pluggings are already installed in the Installed section.

Making New Project in IntelliJ

a. File → New → Project

b. Here you should select the JDK version of your project.

c. Select Maven and then click on Next

d. Enter the project name as you preferred and then you can fill artifact coordinated accordingly. group-id etc… and then finish.

Here is the view of your newly created project.

6.Add Selenium dependencies

All the external libraries that you want within the project can be added as dependencies to the pom.xml file. Maven has an excellent feature to automatically download the dependencies in pom.xml from the central repository to your local. So you don’t need to download and locate those in your local. Let see how we can do it.

a. Go to maven central repository.

b. Search dependencies for “Selenium java”

c. Select the Selenium Java “ org.seleniumhq.selenium”

d. Select a relevant and stable version. (You can check the usages)

f. Copy the code

g. Go to your pom.xml file

h. Open tags for dependencies and paste the piece of code.

i. add other dependencies as same as we have done this.

e. After modifying the pom.xml press the refresh icon to download all the dependencies files from the central repository to the local repository.
After all, files are downloaded from the central repository to the local repository it will appear as done with a tick mark. (See below topic pom.xml)

7. Add the web driver (GekoDriver — Mozzila firefox)

GeckoDriver is a link between Selenium tests and the Firefox browser.

For Mozilla Firefox till version 47, we never needed GeckoDriver. But the Mozilla Firefox after version 47, comes with Marionette, which is an automation driver for Mozilla’s.

a. Locate the Geko driver exe inside the project as below.

b. test → java → right-click → New → Package

c. Package name -GekoDriver

d. Download Gekodriver for your computer.

e. Restore the .exe file in the GekoDriver package

f. Install the driver by .exe file

If you want to download Chrome Driver instead of Geko driver go to the Selenium dev site.

a. Select the Chrome driver

b. Then you will be able to see the latest versions and the stable version details of the driver.

c. Once you select one, click on a suitable zip file for you.

d. Then you can see the exe in the download directory.

e. If you want to check the version just double click on it.

f. Locate this as same as we have done in the Geko driver.

7. Create a New java class file for the test

a. Go to your project → right click on java → New → Java Class

b. Give a suitable name → select on “Class” → Press Enter

c. Your empty class will appear like this.

First codes to automate the browser to navigate to

Important things in your project you should know


pom. xml is an XML file located in the root directory of your project. The pom.xml file contains

  • information about the project
  • packages we used in the project
  • various configuration detail used by Maven to build the project

Before creating a POM, we should first decide the project group (groupId), its name (artifactId), and its version as these attributes help in uniquely identifying the project in the repository.

Sample code

After modifying the pom.xml press the refresh icon to download all the dependencies files from the central repository to the local repository.

After all, files are downloaded from the central repository to the local repository it will appear as done with a tick mark.

After doing it save the pom.xml and run the cleaner to clean the cash.

To copy the codes you need for dependencies can be found in the below link.

search for the artifact you need

Then select one from with highest usages


Simply copy the dependency and modify the pom.xml file.

Do not forget to update the version in the properties section.

I’m using the Mozilla Firefox browser for this testing. So here I have to download the Geko driver to perform the tests.


A JUnit Runner is a class that extends JUnit’s abstract Runner class. Runners are used for running test classes.

Junit Runner class is highly customizable and lets you change the whole test execution process. The Runner that should be used to run a test can be set using the @RunWith annotation.

  1. test → java → right-click → New → Package

2. Package name- Runner

3. Right-click on the Runner package → New → java class

4. New class name — TestRunner

Example code for Test Runner class

Things in runner class

  1. @RunWith(Cucumber.class) — JUnit annotation

2. features={“src/test/java/features” — Path to feature folder where cucumber test scenarios exist

3. plugin = {“pretty”, “html:target/cucumber.html”,”json:target/cucumber.json” — Reporting

4. glue = {“src/test/java/steps/MyLogin”} — Path to Step definition class of scenario

*Creating Feature file — (Cucumber)

a. Features → Right-click → New → File

b. Name — <name.feature>

Then the system will automatically take it as a cucumber file.

In the cucumber file you have to write your test scenario as below by using keywords Scenario, Given, When, And, Then.

Until you create the java class for the step definition the scenario will highlight as below picture.

Create Step definition java class

Prass Alt + Ctrl+B and then the list of suggested intention actions opens.

Select create all step definitions.

You have to give the java file name and select the type of the file as Java.

Then the file location will automatically display as per created file structure.

According to the above-given scenario below java class will create.

since I’m going to automate a logging page I will modify the Step definition java file as below.

selenium java cheat sheet