• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Programming Languages
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
  • Automation Tools and Different Tools
    • Web Automation
      • Selenium with Java
        • Selenium Basic
        • Selenium Advance
        • Selenium Realtime
        • Framework
        • Selenium Interview
        • Selenium Videos
        • Selenium with Docker
      • Selenium with Python
      • WebdriverIO
        • Selenium Webdriver C# Tutorial
      • Cypress
      • Playwright
    • TestNG
    • Cucumber
    • Mobile Automation
      • Appium
    • API Testing
      • Postman
      • Rest Assured
      • SOAPUI
    • testRigor
    • Katalon
    • TestProject
    • Serenity BDD
    • Gradle- Build Tool
    • RPA-UiPath
    • Protractor
    • Windows Automation
  • Automation For Manual Testers
  • Services
  • Online Training
  • Contact us
  • About me
  • Follow us
    • Linkedin
    • Facebook Group
    • Facebook Page
    • Instagram

Automation

Selenium WebDriver tutorial Step by Step

You are here: Home / Cucumber Tutorials / How to integrate Cucumber with Selenium webdriver

How to integrate Cucumber with Selenium webdriver

June 4, 2016 by Mukesh Otwani 22 Comments

Selenium Cucumber Tutorials

Welcome to all of you for another series “Cucumber tutorials”. In this post, we will discuss how to integrate cucumber with selenium webdriver.

What is BDD-  BDD stands for Behavior driven development– This mainly deals with the behavior of the application.

In BDD we only focus on application behavior, all requirements will be in the plain text file and in pure English language. It helps client, developer and tester to understand the requirement easily.

 

What is Cucumber– It is BDD tool which will allow you to perform the test in an easy way.

It is purely written in Ruby and we can implement cucumber in multiple languages. Here we will mainly focus on Java part so complete series will be cucumber with selenium webdriver using Java.

 

Cucumber with Selenium webdriver

Once you are done with this tutorial you will get a clear picture of Cucumber with Selenium webdriver and advantage of using the same.

We will also use Gherkins keywords in our feature files which make our task easy to write user stories in a more efficient way.

 

Below is the example of some Gherkins keyword

  • Feature
  • Scenario
  • Given, When, Then, And, But (Steps)
  • Background
  • Scenario Outline
  • Examples

 

Check example of feature file

Feature: Test Facebook smoke scenario

Scenario: Test login with valid credentials
Given Open firefox and start application
When I enter valid username and valid password
Then user should be able to login successfully

 

Steps for configuring Cucumber with Selenium webdriver

Precondition- Selenium basic is required if you have not gone through Basic tutorials then below link will help you.

Basic Selenium webdriver tutorials

Step 1- Create Java project

Step 2- Add Selenium jars and add Cucumber jars

Step 3- Create feature file and write scenarios.

Step 4- Write TestRunner and execute the same.

Step 5- Once TestRunner execution complete, you will get all methods with default implementation (Copy all of them).

Step 6- Create Java program and paste the code which we have copied in Step 5

Step 7- Write the code for methods which has no body

Step 8- Execute the Test Runner and check the result.

 

Complete project structure will be like

Cucumber with Selenium webdriver

I have also uploaded the complete video on Cucumber with Selenium webdriver

 

 

In next post,we will see the writing of  TestRunner and  stepDefination and feature file.

 

Filed Under: Cucumber Tutorials

Reader Interactions

Comments

  1. Apu says

    February 2, 2021 at 2:33 AM

    Hi Mukesh ,

    Can you please send me the link for reading data from excel using cucumber with selenium.

    Regards
    Apu

    Reply
    • Mukesh Otwani says

      February 3, 2021 at 1:49 PM

      Hi Apu,

      As such I don’t have such post where reading excel during BDD execution. But reading excel is nowhere related to BDD or any other framework. You need to implement your own custom method to read data according to your need. You can check this link which mentions how to read excel file using Apache POI https://learn-automation.com/read-and-write-excel-files-in-selenium/

      Reply
  2. Atul Vani says

    January 11, 2017 at 10:44 PM

    Hi Mukesh, I’m using cucumber 1.1.2 jars as you mentioned in your first video tutorial, but by using this jar file at “@Cucumber.Options ” I am unable to pass plugin parameter for generate HTML report. you also mentioned in your “Maven setup video tutorial” that for “@CucumberOptions” we need to configure latest jars. which jar file versions supported for “@CucumberOptions”, please guide me for this problem.

    Reply
    • Mukesh Otwani says

      January 19, 2017 at 12:33 PM

      Hi Atul,

      Please follow this video https://www.youtube.com/watch?v=WYdTkTzGFxE&index=3&list=PL6flErFppaj1Ogn82-OINRkPwoieZ2dEX&t=2s and use new version

      Reply
  3. Suba Kumaran says

    December 5, 2016 at 1:46 PM

    Hi Mukesh,
    Thank you very much.

    Reply
    • Mukesh Otwani says

      December 6, 2016 at 12:03 PM

      Welcome Suba. Keep learning.

      Reply
  4. akhil says

    October 15, 2016 at 1:31 PM

    Is it possible to use TestnG and Cucumber together

    Reply
    • Mukesh Otwani says

      October 16, 2016 at 12:50 PM

      Nopes as of now only Junit is supportable.

      Reply
  5. swathi says

    September 15, 2016 at 2:14 PM

    hey mukesh, i need a suggestion!

    I started my carrer in testing with selenium webdriver with java , i dont know the logic coding in java and worried about java so i think to change into selenium webdriver with python ? is there future for python ? selenium webdriver in cucumber with java or python is preffered ???

    Please describe with your valuable suggestions for my future

    Thanks in advance

    Reply
    • Mukesh Otwani says

      September 15, 2016 at 4:36 PM

      Hi Swathi,

      Java and Python both are good. I would suggest continue with Java-Selenium-Cucumber.

      Reply
  6. puneeth says

    July 28, 2016 at 12:57 PM

    Hi Mukesh, i am facing an issue with the TestRunner.java class when i am using the plugin option.
    It says “The attribute plugin is undefined for the annotation type CucumberOptions”.

    It plugin option is not given in the suggestion by eclipse. Please suggest.

    Reply
    • Mukesh Otwani says

      August 2, 2016 at 12:39 PM

      Hey Puneeth,

      This will help https://www.youtube.com/watch?v=WYdTkTzGFxE

      Reply
  7. Ali says

    July 13, 2016 at 12:48 PM

    Hi Mukesh,

    I am learning automation from past 4 months i got a good rasp over selenium.Now, i want to use cucumber (BDD Framework)with selenium,please share videos on “selenium with Cucumber” on my mail account as youtube.com is not permitted in my office.

    Reply
    • Mukesh Otwani says

      July 14, 2016 at 11:12 AM

      Hey Ali,

      You can download from outside network and try the same.

      Reply
  8. pankaj says

    June 25, 2016 at 5:01 PM

    Hi mukesh
    i am trying to integerate cucumber maven with jenkins but it ask for maven path but i am not downloading the maven i just add the dependencies in pom.xml file .then what i need to do to execute my cucumber pom.xml with jenkins

    Reply
    • Mukesh Otwani says

      July 2, 2016 at 3:14 PM

      Hey Pankaj,

      Jenkins check local maven first to run maven project.

      Reply
  9. Richa Bansal says

    June 21, 2016 at 6:52 PM

    Hi Mukesh!

    Thank you very much..
    I have extracted all the jars individually..

    Reply
    • Mukesh Otwani says

      July 2, 2016 at 3:23 PM

      Great Richa keep exploring

      Reply
  10. Vishal Kopkar says

    June 17, 2016 at 1:05 PM

    Hi Mukesh,
    Thanks a lot for this useful information. for an update @Cucumber.Options annotation is deprecated and you need to use @CucumberOptions instead.

    Reply
    • Mukesh Otwani says

      June 20, 2016 at 12:10 PM

      Thanks Vishal I will update the same.

      Reply
  11. swati says

    June 15, 2016 at 3:01 PM

    Hi Mukesh,

    I’m using a selenium hybrid framework where we are using batch excel to execute the testmethods. I want to integrate this with Jenkins. Is it possible to integrate with any framework type or do I specifically need TestNG framework?

    I have come across only TestNG integration examples. Can you please suggest on this?

    Thanks,
    Swati

    Reply
    • Mukesh Otwani says

      June 20, 2016 at 12:16 PM

      Hey Swati,

      if you have batch file then in Jenkins you can run any batch file. Select execute window command and mention batch file.

      Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Free Selenium Videos

https://www.youtube.com/watch?v=w_iPCT1ETO4

Search topic

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?

Stay connected via Facebook

Stay connected via Facebook

Archives

Footer

Categories

Recent Post

  • API Testing Using Postman And RestAssured
  • Disable Personalise Your Web Experience Microsoft Edge Prompt In Selenium
  • How To Fix Error: No tests found In Playwright
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Best and easy way to Group test cases in selenium

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?