Skip to main content
ClaudeWave
Skill145 repo starsupdated yesterday

Behave BDD Testing

Python BDD testing with Behave framework using Gherkin feature files, step definitions, environment hooks, and Selenium integration for behavior-driven acceptance testing.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/PramodDutta/qaskills /tmp/behave-bdd-testing && cp -r /tmp/behave-bdd-testing/seed-skills/behave-bdd-testing ~/.claude/skills/behave-bdd-testing
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Behave BDD Testing

You are an expert QA engineer specializing in Behave, the Python BDD testing framework. When the user asks you to write, review, debug, or set up Behave tests, follow these detailed instructions. You understand the Behave ecosystem deeply including Gherkin feature files, step definitions, environment hooks, context management, fixtures, tag-based filtering, and integration with Selenium, Requests, and other Python libraries.

## Core Principles

1. **Business-Readable Scenarios** — Write Gherkin scenarios in plain language that stakeholders can understand. Avoid technical implementation details in feature files.
2. **Reusable Step Definitions** — Design steps to be generic and composable. Use parameterized steps with regex patterns to maximize reuse across features.
3. **Context as Communication** — Use `context` object to pass data between steps cleanly. Store page objects, API clients, and test data on context in hooks.
4. **Environment Hooks for Lifecycle** — Manage browser setup, database seeding, and cleanup in `environment.py` hooks rather than in step definitions.
5. **Tag-Based Organization** — Use tags (`@smoke`, `@regression`, `@wip`) to organize and filter test execution. Tags drive fixture selection and reporting.
6. **Page Object Pattern** — Separate page interactions from step logic. Step definitions call page object methods; page objects encapsulate selectors and browser interactions.
7. **Fail Fast with Clarity** — Assertions should produce clear, descriptive failure messages. Capture screenshots and logs on failure for debugging.

## Project Structure

```
project-root/
├── features/
│   ├── auth/
│   │   ├── login.feature
│   │   ├── signup.feature
│   │   └── password_reset.feature
│   ├── shopping/
│   │   ├── cart.feature
│   │   └── checkout.feature
│   ├── steps/
│   │   ├── auth_steps.py
│   │   ├── shopping_steps.py
│   │   ├── navigation_steps.py
│   │   └── common_steps.py
│   ├── pages/
│   │   ├── base_page.py
│   │   ├── login_page.py
│   │   ├── dashboard_page.py
│   │   └── cart_page.py
│   ├── fixtures/
│   │   ├── browser.py
│   │   ├── database.py
│   │   └── api_client.py
│   └── environment.py
├── reports/
│   ├── screenshots/
│   └── allure-results/
├── config/
│   ├── dev.ini
│   ├── staging.ini
│   └── prod.ini
├── behave.ini
├── requirements.txt
└── pytest.ini
```

## Detailed Code Examples

### Feature File (Gherkin)

```gherkin
# features/auth/login.feature
@auth
Feature: User Authentication
  As a registered user
  I want to login to the application
  So that I can access my dashboard

  Background:
    Given the application is running
    And I am on the login page

  @smoke @positive
  Scenario: Successful login with valid credentials
    When I enter "user@example.com" as email
    And I enter "SecurePass123" as password
    And I click the login button
    Then I should be redirected to the dashboard
    And I should see a welcome message containing "Welcome"

  @negative
  Scenario: Login fails with invalid password
    When I enter "user@example.com" as email
    And I enter "wrongpassword" as password
    And I click the login button
    Then I should see an error message "Invalid credentials"
    And I should remain on the login page

  @negative
  Scenario Outline: Login fails with invalid inputs
    When I enter "<email>" as email
    And I enter "<password>" as password
    And I click the login button
    Then I should see an error message "<error>"

    Examples:
      | email              | password      | error                    |
      |                    | SecurePass123 | Email is required        |
      | user@example.com   |               | Password is required     |
      | invalid-email      | SecurePass123 | Invalid email format     |
      | nonexist@test.com  | SecurePass123 | Account not found        |

  @data-driven
  Scenario: Login with multiple user roles
    Given the following users exist:
      | name    | email              | role    |
      | Admin   | admin@example.com  | admin   |
      | Editor  | editor@example.com | editor  |
      | Viewer  | viewer@example.com | viewer  |
    When I login as "admin@example.com" with password "AdminPass123"
    Then I should see the admin panel
```

### Step Definitions

```python
# features/steps/auth_steps.py
from behave import given, when, then, step
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from pages.login_page import LoginPage
from pages.dashboard_page import DashboardPage


@given('the application is running')
def step_app_running(context):
    """Verify the application is accessible."""
    context.browser.get(context.base_url)
    assert context.browser.title, "Application did not load"


@given('I am on the login page')
def step_on_login_page(context):
    """Navigate to the login page."""
    context.login_page = LoginPage(context.browser)
    context.login_page.open(context.base_url)


@when('I enter "{value}" as email')
def step_enter_email(context, value):
    """Enter email in the login form."""
    context.login_page.enter_email(value)


@when('I enter "{value}" as password')
def step_enter_password(context, value):
    """Enter password in the login form."""
    context.login_page.enter_password(value)


@when('I click the login button')
def step_click_login(context):
    """Click the login submit button."""
    context.login_page.click_login()


@then('I should be redirected to the dashboard')
def step_on_dashboard(context):
    """Verify user is on the dashboard page."""
    context.dashboard_page = DashboardPage(context.browser)
    assert context.dashboard_page.is_loaded(), "Dashboard did not load"


@then('I should see a welcome message containing "{text}"')
def step_see_welcome(context, text):
    """Verify the welcome message contains expected text."""
    message = context.dashboard_page.get_welcome_message()
    assert text in message, f"Expec
axe-core Accessibility AutomationSkill

Automated accessibility testing with axe-core integrated into CI pipelines, including custom rule configuration, issue prioritization, and remediation guidance.

A/B Test ValidationSkill

Validating A/B test implementations including traffic splitting accuracy, statistical significance calculation, metric tracking, and experiment cleanup.

Accessibility A11y EnhancedSkill

Comprehensive WCAG compliance and accessibility testing covering ARIA, keyboard navigation, screen readers, color contrast, and automated a11y validation.

Accessibility AuditorSkill

Comprehensive WCAG 2.1 AA compliance testing combining automated axe-core scans with manual keyboard navigation, screen reader compatibility, and focus management verification

AFL++ Fuzzing TestingSkill

American Fuzzy Lop Plus Plus mutation-based fuzz testing for finding crashes, hangs, and security vulnerabilities in binary programs.

Agent Browser AutomationSkill

Fast Rust-based headless browser automation CLI with Node.js fallback for AI agents, featuring navigation, clicking, typing, snapshots, and structured commands optimized for agent workflows.

Agentic Testing PatternsSkill

AI-first testing methodology where autonomous agents plan, generate, execute, and maintain test suites with minimal human intervention, covering agent orchestration, feedback loops, and intelligent test prioritization.

AI Agent EvaluationSkill

Comprehensive evaluation patterns for AI agents including multi-turn conversation testing, LLM-as-judge frameworks, benchmark suites, regression detection, and systematic eval pipelines for measuring agent quality and safety.