📊

Selenium and Maven BDD Framework Guide

May 21, 2025

Selenium Java Maven BDD Framework Setup and Testing Course

Course Overview

  • Comprehensive course on setting up and testing with Selenium, Java, Maven, Cucumber, WebDriver Manager, and Allure Reporting.
  • Use of Behavior-Driven Development (BDD) framework.
  • Final output: automated beautiful reports.

Tools and Frameworks

  • Programming Language: Java
  • Automation Test Tool: Selenium
  • Automation Test Framework: BDD (Behavior-Driven Development)
  • Cucumber: BDD Tool
  • Webdriver Manager: Automates driver management for browsers
  • Maven: Build tool for Java projects
  • IDE: IntelliJ IDEA

Setup Steps

Step 1: Install IntelliJ

  • Download from the official website (Community Edition free).
  • Installation usually defaults to C drive.

Step 2: Verify and Install Java

  • Verify Java version using java --version in command prompt.
  • If not installed, download Java (Oracle link recommended).
  • Set environment variables for Java:
    • System variable: JAVA_HOME
    • Update PATH variable with the bin directory of JDK.

Step 3: Verify and Install Maven

  • Verify with mvn --version.
  • If not installed, download Apache Maven.
  • Set environment variables for Maven:
    • System variable: M2_HOME
    • Update PATH variable with the bin directory of Maven.

Step 4: Create Maven Project

  • Open IntelliJ and create a new Maven project.
  • Set up project name and file paths.

Step 5: Install Cucumber Dependencies

  • Add Cucumber dependencies (Cucumber-Java, Cucumber-JUnit, Cucumber-Core) in pom.xml.
  • Ensure matching versions for compatibility.

Step 6: Install Selenium WebDriver

  • Add Selenium WebDriver dependency in pom.xml.
  • Use WebDriverManager for driver management (no need for manual driver installation).

Step 7: Setup Project Structure

  • Create package structure for features, pages, runner, stepDefinitions, utility.

BDD Framework Explanation

  • Allows creating readable automated tests in natural language.
  • Uses Given-When-Then format.
  • Example: User stories and scenarios using straightforward language.

Application Under Test

  • Live Demo Application: Online Shoe Portal
  • Test Scenarios:
    1. User navigates and logs in to view product categories.
    2. New user registration scenario.
    3. General user navigates to view products.

Design Page Object Model (POM)

  • Page Classes: HomePage, LoginPage, RegistrationPage, OnlineProductsPage.
  • Operations: Define objects and associate operations (e.g., clicks, inputs).

Step Definitions

  • Create step definitions to implement scenario steps.
  • Map feature file steps to Java methods.

Testing

Running Tests

  • Tests involve automated browser actions (e.g., opening URLs, clicking links).
  • Use of WebDriverManager to manage browser version consistency.
  • Run tests through feature files or TestRunner for batch execution.

Reporting

  • Basic HTML Reporting: Use Cucumber plugin to generate basic HTML reports.
  • Allure Reporting: More advanced and visually appealing.
    • Install Allure plugin in IntelliJ.
    • Configure pom.xml for Allure.
    • Generate reports using command line (npm and Alure results).

Conclusion

  • Comprehensive coverage of setting up an automated testing framework using Selenium and associated tools.
  • Focus on BDD methodology for improved collaboration and readable test scripts.
  • Use powerful tools for test management and reporting (Cucumber and Allure).