Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ A modular, pytest-based **Playwright (Python)** framework for web UI testing.
```

3. **Bootstrap once (signup → login → save session)**
> **Note:** This step is recommended but not required — if `storage_state.json` is missing, pytest will automatically bootstrap the session before running any tests.

```bash
python -m scripts.bootstrap_signup --name "Jane Doe" --email "[email protected]" --password "StrongPass123"
```
Expand All @@ -32,7 +34,7 @@ A modular, pytest-based **Playwright (Python)** framework for web UI testing.
```
> Tip: to **watch it in a real browser**, run headed:
> ```bash
> HEADLESS=false pytest -s tests/test_logged_in_session.py
> HEADLESS=false pytest -s tests/test_logged_in.py
> ```

5. **Run the full suite**
Expand Down
13 changes: 13 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,16 @@ def page(context):
yield p
finally:
p.close()

# --- Database & Data Validation Lifecycle ---

@pytest.fixture(scope="session")
def db_engine():
"""
Spawns a mock SQLAlchemy engine structure for backend integration and DataFrame testing.
e.g., engine = sqlalchemy.create_engine('sqlite:///:memory:')
"""
# engine = None
# yield engine
# engine.dispose()
yield "mock_engine_connection"
16 changes: 16 additions & 0 deletions data_clients/db_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class DatabaseClient:
def __init__(self, engine):
self.engine = engine

def get_user_data(self, user_id):
"""
Skeleton method to return a DataFrame of user data.
In reality, this would use pandas.read_sql or SQLAlchemy.
"""
pass

def get_system_snapshot(self, system_name):
"""
Skeleton method to pull large-scale dataset snapshots.
"""
pass
35 changes: 35 additions & 0 deletions data_driven_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
def run_signup_from_csv(csv_path="users.csv", headed=True):
import csv
from pathlib import Path
from playwright.sync_api import sync_playwright, expect

URL = "https://faruk-hasan.com/automation/signup.html"
rows = list(csv.DictReader(Path(csv_path).open(newline="", encoding="utf-8")))

with sync_playwright() as pw:
browser = pw.chromium.launch(headless=not headed)
context = browser.new_context()

for u in rows:
page = context.new_page()
try:
page.goto(URL, wait_until="domcontentloaded")
expect(page).to_have_title("Sign Up - Automation Practice")

page.locator("#username").fill(u["name"].strip())
page.locator("#email").fill(u["email"].strip())
page.locator("#password").fill(u["password"].strip())
page.locator("#confirmPassword").fill(u["password"].strip())
page.get_by_role("button", name="Sign Up").click()

# Let any redirect/JS complete before closing this page
page.wait_for_load_state("networkidle", timeout=7000)
print(f"✅ Signed up: {u['name']} ({u['email']})")
finally:
page.close()

browser.close()


if __name__ == "__main__":
run_signup_from_csv("users.csv", headed=True)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ pytest>=8.0.0
playwright>=1.45.0
pytest-playwright>=0.5.0
python-dotenv>=1.0.1
pandas>=2.0.0
numpy>=1.24.0
SQLAlchemy>=2.0.0
14 changes: 14 additions & 0 deletions tests/data_quality/test_data_anomalies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest
from utils.data_validation.dataframe_utils import DataFrameValidator
from data_clients.db_client import DatabaseClient

def test_large_scale_data_stability(db_engine):
"""
A skeleton test representing a data stability check.
It expects the 'db_engine' fixture from conftest.py.
"""
# client = DatabaseClient(db_engine)
# df = client.get_system_snapshot("production_replica")
# validator = DataFrameValidator()
# validator.assert_no_anomalies(df)
pass
4 changes: 4 additions & 0 deletions users.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name,email,password
Admin,[email protected],Pass123
User,[email protected],Pass456
Manager,[email protected],Pass789
17 changes: 17 additions & 0 deletions utils/data_validation/dataframe_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pandas as pd
import numpy as np

class DataFrameValidator:
@staticmethod
def assert_no_anomalies(df: pd.DataFrame, threshold: float = 0.05):
"""
Checks if the number of nulls exceeds a threshold.
"""
pass

@staticmethod
def compare_snapshots(pre_df: pd.DataFrame, post_df: pd.DataFrame) -> pd.DataFrame:
"""
Returns a diff between pre-code and post-code system states.
"""
pass