Learn how to setup a Selenium WebDriver 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 https://mvnrepository.com/ and search for the following dependencies.
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 “TestRunner.java”.
13. Enter the following in the TestRunner.java 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
Full Stack Test Automation Expert | Selenium Framework Developer | Certified Tosca Automation Specialist | Postman | DevOps | AWS | IC Agile Certified | Trainer | Youtuber | Blogger|