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
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.
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
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.