Getting Started with BDD Cucumber in Catalon

Aug 26, 2024

Automation Tutorial on BDD Cucumber Framework Using Catalon

Introduction

  • This is Lesson 23 focusing on BDD Cucumber Framework using Catalon.
  • Previous videos covered various concepts of automation (22 videos).
  • This session is the first part of a multi-part series on BDD with Catalon.
  • Reminder to subscribe and click the bell icon for notifications on new videos.

Agenda for Part 1

  1. Create a project in Catalon Studio.
  2. Create feature files using Catalon Studio.
  3. Create step definitions for the created feature files.
  4. Run the feature files.
  5. Parameterize feature files with different test data sets.
  6. Run the parameterized feature files using Catalon Studio.

Step 1: Create a Project in Catalon Studio

  • Open Catalon Studio.
  • Create a new project:
    • Click on File > New > Project.
    • Name the project as BDD Cucumber Framework.
    • Select Web as the project type and click OK.

Step 2: Create Feature Files

  • Navigate to the Include folder in the project.
  • Create a features folder if not present.
  • Right-click in the features folder and create a new feature file named login.feature.

Example Feature File Structure

  • The structure of a typical feature file includes:
    • Feature:
      • Example: Feature: Login Feature
    • Scenario:
      • Example: Scenario: Test login with valid credentials
    • Steps:
      • Given: Precondition
      • When: Action
      • Then: Expected outcome

Step 3: Define Step Definitions

  • Create Step Definitions for each feature step.
  • Expand Scripts in the left pane, right-click on Groovy, and select New > Step Definition to create login steps.

Example Step Definitions

  • Use println statements to simulate actions.
  • Each step definition should include:
    • At the rate keyword (e.g., @Given, @When, @Then)
    • Function definitions with print statements.

Step 4: Running the Feature File

  • Right-click on login.feature and select Run as Cucumber Feature to execute the scenarios.
  • Check the Log Viewer for the output of each step.

Step 5: Parameterization of Feature Files

  • To test with multiple data sets, use Scenario Outline and Examples:
    • Define parameters in the feature file using angle brackets: <username> and <password>.
    • Change Scenario to Scenario Outline and define Examples below.

Example for Parameterization

Scenario Outline: Test login with valid credentials
  Given user navigates to login page
  When user enters <username> and <password>
  Then user is navigated to registration page

Examples:
  | username | password |
  | ravikant | 12345    |
  | chandu   | 12345    |

Updating Step Definitions for Parameterization

  • Modify the step definitions to accept parameters for username and password.
  • Use regular expressions to match parameters in the step definitions.

Conclusion

  • The session covered the basics of setting up a BDD Cucumber Framework using Catalon.
  • The next session will demonstrate a real-time example with proper coding in Groovy.
  • Encourage viewers to leave queries in the comments for further assistance.
  • Reminder to subscribe for updates on the next sessions.