A Behavior-Driven Development (BDD) framework that leverages Python, Playwright, Behave, Allure, and OpenAI for automated web application testing.
-
Clone the Repository
git clone https://github.com/FaraziF/AI_BDD_BASIC_FRAMEWORK.git cd AI_BDD_BASIC_FRAMEWORK -
Create and Activate a Virtual Environment (Recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
If
requirements.txtis missing, install manually:pip install behave playwright allure-behave openai
-
Install Playwright Browsers
playwright install
-
Set Up Configuration Files
- Create
config/openai_key.jsonwith your OpenAI API key:{ "api_key": "YOUR_OPENAI_API_KEY" } - Create
config/env.jsonfor browser settings:{ "browser": "chromium", "headless": false }
- Create
Automatically generate Gherkin scenarios for the "Contact Us" form:
python run_tests.pyThis will generate or update features/contact_form.feature.
Execute BDD tests and generate Allure result files:
python custom_runner.py- Cleans/creates
reportsandscreenshotsfolders. - Runs all scenarios tagged with
@regression. - Outputs results to
reports/allure-results.
Generate and open the Allure HTML report:
allure generate reports/allure-results -o reports/allure-report --clean
allure open reports/allure-reportfeatures/- Gherkin feature files and step definitions.features/steps/- Python step implementations for Behave.features/environment.py- Hooks for setup/teardown (browser, Playwright).config/- Configuration files (openai_key.json,env.json, etc).utils/- Utility modules (OpenAI integration, step analysis, types).run_tests.py- Script to generate Gherkin scenarios using OpenAI.custom_runner.py- Custom test runner with Allure integration.
- Edit or add feature files in
features/. - Step definitions are in
features/steps/contact_us_form_steps.py. - OpenAI Integration: Used for scenario and step suggestion/generation.
- Allure Reporting: Screenshots and test results are integrated with Allure.
- Python 3.8+
- Playwright
- Behave
- Allure
- OpenAI Python SDK