The use of a BDD (Behavior Driven Development) framework for automated quality assurance is not unheard of, but it is controversial. Today, we’d like to discuss the advantages and disadvantages of using the Cucumber.js framework with Selenium, as well as some potential use cases.

To begin, let’s talk quickly about Selenium Webdriver.

Simply put, what is Selenium?

An open-source, cross-platform automation testing instrument that facilitates the creation of automated tests in a wide variety of languages (e.g., JavaScript, Java, Python, Perl, etc.) and their execution across several browsers (not only Chrome and Firefox).

The Selenium WebDriver API allows us to automate user interfaces by interacting with dynamic web pages and their components.

The traditional method of developing Selenium code is via the use of the POM (Page Object Model). Here, a test engineer has complete freedom to experiment with different scenarios by visiting other websites and engaging with their various features.

We often use POM for keeping track of web components and their activities for a certain web page inside a given JS file in order to improve code maintenance and dependability. Take the following “user-login.js” page object file as an example.

module.exports = {
  url: '',
  // WebElement Locators
  elements: {
    nextButton: by.css('div > label > button')
  // Actions on WebElements
  navigateToNextPage: function () {
    var selector = page.userLogin.elements.nextButton;
    return driver.findElement(selector).sendKeys(selenium.Key.ENTER);

What is Cucumber JS?

Using the BDD (Behavior Driven Development) technique, this software solution helps teams of developers, testers, analysts, product managers, and business people work together more closely throughout the software testing phase. It builds a common language on top of your automated testing code in Selenium JS.

For BDD, the first step is to identify the feature or user narrative that has to be automated, then to create its specifications in the Gherkin language, and last to develop its test cases using the Given-When-Then methodology. Cucumber verifies whether the programme operates as planned. There are a number of possible outcomes specified in this document.

In the first step of the Cucumber automation methodology, called “Discovery,” a tester realizes that he needs to automate the website’s login page.

To begin, a tester creates a feature file outlining the software specification procedures for what should be automated and how.

The testing process is automated by having the tester define steps in Java script. Your code to make those steps valid is included.

Advantages of Cucumber JS in BDD

The advantages of using the Given-When-Then syntax in Gherkin are clear. Specifically designed for use with Cucumber, this language fosters readability to bridge the gap between business stakeholders and test engineers.

Gherkin also provides some additional advantages. Let’s say you have two separate APIs that require their authorisation processes to be automated. Your initial inclination may be to create two identical scenarios for each API. Instead of doing that, you may use Gherkin’s “Scenario Outline” and “Examples” table to avoid duplication.

Drawbacks of Cucumber JS

However, there are drawbacks to using Cucumber and Gherkin together. The complexity for testers has increased as they are now expected to write generic procedures that may be utilized in more than one scenario or feature.

Maintaining code reusability is a time-consuming effort since the tester must keep track of which steps in a feature file may be applied to an untested feature.

Another key drawback is that when a business person or an analyst suggests any modifications to a test case, the process quickly breaks, despite Cucumber’s primary purpose of increasing communication between all team members. They simply won’t be able to apply these modifications without understanding the underlying code structure, hence there is a tiny potential that such stages may be modified or omitted.

Because each step in Gherkin has its own function name, testers are forced to use more words.

In addition, as an additional layer, Cucumber isn’t making the test framework more resilient (in fact, it’s doing the reverse). And the more test cases the organization will have, the more time will be spent on daily test maintenance.


For those of you who aren’t aware of testRigor yet, it’s a robust replacement for Selenium and Cucumber that avoids their flaws. Anyone on the team will be able to read, understand, and make changes to requirements written in plain English (not Gherkin). Even the most complicated end-to-end UI tests may be done with no additional layers and without the need for any coding expertise. Using a cloud-based platform for testing guarantees unmatched test stability and reliability.