Friday, March 3, 2017

How Create Maven Project for Selenium - Cucumber Automation?

In First Test Case in Selenium with Cucumber post we created java project and added all the required Jars to project build path. This involved more manual intervention work like downloading jars one by one from Maven Central Repository. But in Maven project we will avoid that maven intervention by adding all the dependencies in pom.xml.

Dependencies Required for Maven Project for Selenium with Cucumber:
        1. cucumber-java
        2. cucumber-junit
        3. junit
        4. selenium-standalone-server
Follow the below steps :
Step 1: Install Maven Plugin in Eclipse IDE

Step 2: Create the maven project, Select File > Other > Maven > Next
Step 3: Provide Group ID and Artifact ID and Click Finish. That’s it maven project is created.
Step 4: The maven project should be created.

Step 5: Now add all the Jars required to project by copying the below dependencies to pom.xml file and Save the file (Ctrl+S). Double click on pom.xml to open.

Step 6: We should see Maven Dependencies folder added under project and all jars under it.
Step 7:  Create Features, Test Runner Class, Step Definitions.
  • In Features folder we need create "gmailLogin.feature" and below cucumber tests. 

  • Create a Test Runner Class and the below code.

  • Create a Step Definitions class and the below code.
Please go through my previous post First Test Case in Selenium with Cucumber to understand how to write the cucumber tests in features file and how to create Test Runner class and Step Definitions class.
Step 8: Now go to Test Runner Class "TestRunner.java" Right Click > Run As > Junit. Now the cucumber tests should start executing.

1 comment:

  1. Thanks for providing the information . The articles in your blog helped me a lot for improving the knowledge on the subject. Also check my small collection on this at selenium Online Training Hyderabad blog

    ReplyDelete

Java Program 5: How to reverse given string and each word of it?

Let us understand the problem with an example, suppose "Learn Core Java" is the given string then the expected output should be &...