Setup Selenium Java Maven Project with Cucumber And TestNG

Learn how to setup a Selenium WebDriver project with Cucumber and TestNG

Setup Selenium Java Maven Project with Cucumber And TestNG

In this tutorial, you will learn how to setup Selenium Cucumber Java project with TestNG from scratch


1. Java is installed on Windows

2. Maven is installed on Windows 

3. IntellijIdea is installed on Windows 

Steps to Setup Selenium Cucumber Java Framework with TestNG:

1. Launch IntelliJ Idea and click on New Project.

2. Select Maven as Project type and select a java version in Project SDK. Click on Next.

3. Enter a name for the project (SampleProject) and click on Finish.

4. Once the project setup is completed. Open the pom.xml file

5. Go to and search for the following dependencies.

  • selenium-java
  • cucumber-java
  • cucumber-core
  • cucumber-testng
  • testng

6. Select the latest version of the dependency and copy the details within <dependency></dependency>

7. Go back to pom.xml and add all the following dependencies.

8. Go to src/test/java and right click on New -> Package. Enter a new package “com.example”.

9. Right click on test folder and select New -> Directory. Enter a new directory “resources”.

10. Right click on resources and select New -> Directory. Enter a new directory “features”.

11. Right click on com.sample and select New -> Package. Enter a new package “StepDefintions”.

12. Right click on the package and click on New -> Java Class. Enter a new class “”.

13. Enter the following in the class

14. Right click on the project. Select New -> File.

15. Enter file name as testng.xml in New File dialog box. Click on Enter.

16. Open testng.xml file and paste the below content.

17. Add all your Cucumber Feature files under features folder.

18. Add all your Step Definition files under StepDefinitions folder.

19. Right click on testng.xml file and click on Run.

20. Cucumber reports are generated under target folder – cucumber.html & cucumber.json

Bijan Patel
Full Stack Test Automation Expert | Selenium Framework Developer | Certified Tosca Automation Specialist | Postman | DevOps | AWS | IC Agile Certified | Trainer | Youtuber | Blogger|

Launch your GraphyLaunch your Graphy
100K+ creators trust Graphy to teach online
QASCRIPT 2024 Privacy policy Terms of use Contact us Refund policy