End-to-end test automation framework migrated from the original TypeScript Playwright BDD project to Python.
The project uses:
- Playwright for Python for browser automation
- pytest as the test runner
- pytest-bdd for Gherkin scenarios
- python-dotenv for environment configuration
Install:
- Python 3.10 or newer
- Git
- Visual Studio Code, optional
Clone the repository and enter the project directory:
git clone https://github.com/ArtemOganesyan/typescript-playwright-bdd.git
cd typescript-playwright-bddCreate and activate a virtual environment:
python -m venv .venv
source .venv/bin/activateOn Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1Install dependencies and Playwright browsers:
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m playwright installCreate local environment settings:
cp .env.example .envConfiguration is loaded from .env by config.py.
Important variables:
BROWSER:chromium,firefox, orwebkitHEADLESS:trueorfalseSLOW_MO: delay in milliseconds between Playwright actionsVIEWPORT_WIDTH,VIEWPORT_HEIGHT: browser viewport sizeGLOBAL_TIMEOUT,ACTION_TIMEOUT,NAVIGATION_TIMEOUT,EXPECT_TIMEOUT,WAIT_TIMEOUT: timeouts in millisecondsTEST_QUOTE_BASE_URL: URL for the classic pytest scaffold test
The repository includes .vscode/settings.json so VS Code can discover Python tests and BDD steps:
{
"cucumber.features": [
"bdd/features/**/*.feature"
],
"cucumber.glue": [
"bdd/steps/**/*.py"
],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.pytestArgs": [
"tests"
],
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
}Recommended VS Code extensions:
- Python by Microsoft
- Cucumber by Cucumber.io
After changing extension or workspace settings, run Developer: Reload Window in VS Code.
Run all tests:
pytestRun only BDD tests:
pytest -m bddRun the nopCommerce demo BDD scenario:
pytest -m bdd1Run a single test file:
pytest tests/test_bdd.pyRun tests by name:
pytest -k "Featured"The Microsoft Playwright Test extension for VS Code discovers JavaScript/TypeScript Playwright Test projects. This project uses Python, pytest, and pytest-bdd, so the extension can show no playwright tests found when using its Record button.
Use Python Playwright codegen instead:
python record.pyBy default this opens https://nop-qa.portnov.com/ and saves generated pytest code to tests/recorded_test.py.
You can also run codegen directly:
python -m playwright codegen --target python-pytest --output tests/recorded_test.py https://nop-qa.portnov.com/In VS Code, run the task Record Python Playwright test from Terminal -> Run Task.
HTML report:
open test-reports/report.htmlOn Windows:
start test-reports/report.htmlRuntime artifacts are written to:
test-reports/report.htmltest-reports/videos/test-reports/screenshots/for failed teststest-results/when Playwright creates additional artifacts
.
├── bdd/
│ ├── features/
│ │ └── bdd.feature
│ └── steps/
│ └── bdd_steps.py
├── tests/
│ ├── test_bdd.py
│ └── test_quote_form.py
├── config.py
├── conftest.py
├── pytest.ini
├── requirements.txt
└── .env.example
The original repository contained an empty TypeScript Playwright quote-form test. In this Python version it remains as a lightweight scaffold that opens TEST_QUOTE_BASE_URL and verifies that the page loads with a title.
The BDD scenario uses https://nop-qa.portnov.com/. It verifies featured products and prices, opens a product details page, checks availability, and searches for computer.