What are Features and Step Definitions in Cucumber?

Features: File with “.feature” extension are called features file. A Feature file will contain one feature with one or more Scenarios. A line started with Keyword “Feature” in Feature file is the test feature that cucumber going to execute. Each Scenario in Feature contains number of steps written using Gherkin language.
Step Definitions: Each step in a Scenario mapped to Step definition. When Cucumber executes a Step Scenario it looks for a matching Step Definition to execute. Each step definition is a piece of code defined for certain task. Each step definition is attached with a reference pattern, which is used for map between steps in scenario and step definitions.


How to Encrypt password for Selenium Webdriver

To secure our passwords we can use Base64 encoding scheme in Selenium WebDriver. We will import this Bas64 class in our script to get the decode password.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;
import java.util.Base64;

public class passwordEncryption(){

public static WebDriver driver;

String password = “simpletesters123”;

String encryptedPassword = Base64.getDecoder().decode(decodepassword.getBytes());

driver = new FirefoxDriver();
driver.findElement(By.id(“pass”)).sendKeys(“encryptedPassword “);


Downloading Cucumber JVM and Selenium Jars

To write/run Cucumber Scenarios with Java in Eclipse the below Jar files are required. Please follow the steps and all download the all listed jar files.

  • junit
  • gherkin
  • Cucumber-core
  • Cucumber-java
  • Cucumber-junit
  • Cucumber-jvm-deps
  • Cucumber-reporting
  • mockito-all
  • cobertura

Step 1: Search all the above terms in the Maven Central Repository one by one and download latest Jar file. Click Here!! for Maven repository.


Step 2: Now search for “junit”, you could see the list of Jars listed. Select the latest Jar and download it.


Step 3: Repeat the same procedure for remaining Jars and Keep them in a folder as below.


Step 4: Download the Selenium Standalone Server from Download Selenium Standalone Jar

Step 5: Add all the above Jars in the project build.

Installing Cucumber Eclipse Plugin

Why Cucumber Eclipse Plugin needed? This plugin highlights the Syntax’s or Keywords; basically it distinguishes syntax keywords from other sentences. That is fine if we do not install it but the entire scripts appears as plain text as in a notepad. So it is recommended to install Cucumber Eclipse Plugin.

Installation Steps:

Step 1: launch Eclipse IDE and Go to “Install New Software…” option.


Step 2: In the new dialog window click on “Add” button.


Step 3: Give the Name as “Cucumber” (you can give any name) and paste below URL in Location and click OK.



Step 4: You must see the Cucumber Eclipse Plugin in the software list. Select the Cucumber check-box and Click on Next.


Step 5: Accept the Terms and Conditions and Click on Finish.


Step 6: Installation will start and you may see “Security Warning” just click OK.



Step 7: After Installation completed it will ask Eclipse restart say yes.


Step 8: Now go to Eclipse Help Installation Details. You must is Cucumber Eclipse Plugin in the Installed Software list.


Why Selenium with Cucumber?

In the agile world, the Stake Holders or Business Analysts or Product Owners decides the behavior of systems first and writes System Requirements or System Scenarios in Customer’s point of view. These requirements are reviewed and singed off to Developers for development, this is BDD.

Now the above System Requirements can be easily converted to end user tests using BDD approach. The code can easily read/understandable to Product Owners or Business Analysts. So Selenium with Cucumber is good choice for executing the tests.

Cucumber Introduction

  • Cucumber is an open source software tool used to test the other software. It is a Behavior Driven Development tool.
  • Writing tests is easy and persons with no technical knowledge can understand the tests.
  • Though Cucumber is written in Ruby, supports other languages like Java, Scala, Groovy and etc. Cucumber supports web environment only.
  • Cucumber plugins works faster compared to UFT and Selenium. So the execution is quick in cucumber.