Selenium Integration with Cucumber BDD Tool

cucumber tutorial
Selenium Integration with Cucumber BDD Tool

1) What is Cucumber?

2) What is Selenium?

3) Why Integrating Selenium and Cucumber?

(Use of Selenium with Cumber Integration, and Users of this Test Environment.)

4) Selenium Integration with Cucumber- Environment Setup

(Download & Install Java, Add Selenium WebDriver, TestNG, and Cucumber software dependencies using Maven.)

5) Selenium Integration with Cucumber- Write First Test Case & Execute

(Create ‘Selenium with Cucumber” Project, Create Cucumber Feature file, Create Selenium Test Script for the Cucumber feature file, Create Test Runner using TestNG and execute Cucumber Test & View test Results.)

6) Data Driven Testing using “Selenium with Cucumber Integration

(Create Cucumber Feature File and Test Data, Create Selenium Test scriptfor the Cucumber Feature File Data Driven test Scenario and Execute the Cucumber Data Driven Test.)

Selenium with Java and TestNG Tutorials


Introduction to Cucumber

  • Cucumber is an open source tool to support Behavior Driven Development with plain text specifications, It is not an Automated Test Tool and It can Test Functional behavior of web applications by integrating Selenium or Watir etc, Tools.
  • Behavior Driven Development (BDD) framework is extended version of TDD (Test Driven Development) that supports behavioral part of software code.
  • Cucumber was written in Ruby. Cucumber supports other languages like Java, Net, Javascript and other platforms.
  • Cucumber reads executable specifications written in plain text and validates that the software does what those specifications say.
  • In order for Cucumber to understand the scenarios, they must follow some basic syntax rules, called Gherkin. Gherkin is a simple set of grammar rules that makes plain text structured enough for Cucumber to understand.
  • Cucumber is used to write acceptance tests for web applications, It allows automation of functional validation in easily readable and understandable format (like plain English) to Business Analysts, Developers, Testers, etc.
  • In BDD, users (business analysts, product owners) first write scenarios or acceptance tests that describes the behavior of the system from the customer’s perspective, for review and sign-off by the product owners before developers write their codes.

Advantages of Cucumber

  • It is helpful to involve business stakeholders who can’t easily read code
  • Cucumber Testing focuses on end-user experience

Why Integrating Selenium and Cucumber?

Cucumber and Selenium are two popular technologies.

Most of the organizations use Selenium for functional testing of web applications. these organizations want to integrate Cucumber with Selenium to easy to read and to understand the application flow.

Cucumber tool acts as the bridge among Business Analyst, Software Testers and Software Developers.

Cucumber also benefits the client to understand the application code as it uses Gherkin language which is in Plain Text.

Prerequisites for Behavior Driven Test Development,

BDD Test Tool — to define application behavior in plain meaningful English text using a simple grammar defined by a domain specific language (DSL)– e.g. Cucumber (DSL: Gherkin), JBehave (DSL: Gherkin), Behat (DSL: Gherkin), Mocha (DSL: user-defined)

Test Runner — to automate and run the behavior tests– e.g. TestNG (Java), JUnit (Java) ETC,

Optional IDE plugins — Ex: Cucumber plugin for Eclipse IDEs to enable BDD coding support.

Test Tool – Ex Selenium to write Test Steps for BDD tool like Cucumber Test Specification

Required jar files for Selenium, Java, JUnit/TestNG with Cucumber

cucumber-core
cucumber-java
cucumber-junit
cucumber-jvm-deps
cucumber-html
gherkin
testng
cucumber-testng
cucumber-picocontainer
extentreports
cucumber-extentsreport
selenium-server
webdrivermanager,

Note: If we use Selenium, Java with Cucumber then you can use either JUnit ot TestNG as Test Runner.

Selenium Integration with Cucumber- Test Environment Setup

Eclipse IDE, Maven, Selenium WebDriver, Java, JUnit or TestNG, Cucumber and ExtentsReport etc, software.

Steps:

  • Download & Install Java (JDK) Software
  • Set Java Environment Variable path
  • Download & Extract Eclipse IDE for Java Developers,
  • Install “TestNG” plugin for Eclipse IDE
  • If you want to use JUnit as Test Runner you can use, JNiunt is built-in plugin in Eclipse IDE,
  • Create Maven Project
  • Add the below Maven Software dependecies in Maven POM XML file
    cucumber-core,
    cucumber-java,
    cucumber-junit,
    cucumber-jvm-deps,
    cucumber-html,
    gherkin,
    testng,
    cucumber-testng,
    cucumber-picocontainer,
    extentreports,
    cucumber-extentsreport,
    selenium-server,
    webdrivermanager,
  • Restart Eclipse IDE
    Note: Now Selenium with Cucumber Test Environment is ready.

Selenium Integration with Cucumber- Write First Test Case & Execute

Data Driven Testing using “Selenium with Cucumber Integration

Follow me on social media: