scitex_browser.debugging
- async scitex_browser.debugging.highlight_element_async(element, duration_ms=1000, func_name='highlight_element_async')[source]
Highlight element with red overlay rectangle.
- scitex_browser.debugging.inject_visual_effects(page)[source]
Inject CSS and elements for visual effects (sync version).
- Return type:
- async scitex_browser.debugging.inject_visual_effects_async(page)[source]
Inject CSS and elements for visual effects (async version).
- Return type:
- scitex_browser.debugging.show_cursor_at(page, x, y, state='normal')[source]
Move visual cursor to position (sync version).
- async scitex_browser.debugging.show_cursor_at_async(page, x, y, state='normal')[source]
Move visual cursor to position (async version).
- Return type:
- scitex_browser.debugging.show_click_effect(page, x, y)[source]
Show click ripple effect at position (sync version).
- Return type:
- async scitex_browser.debugging.show_click_effect_async(page, x, y)[source]
Show click ripple effect at position (async version).
- Return type:
- scitex_browser.debugging.show_step(page, step, total, message, level='info')[source]
Show numbered step message in browser (sync version).
- async scitex_browser.debugging.show_step_async(page, step, total, message, level='info')[source]
Show numbered step message in browser (async version).
- Return type:
- scitex_browser.debugging.show_test_result(page, success, message='', delay_ms=3000)[source]
Show test result banner (PASS/FAIL) and wait (sync version).
- async scitex_browser.debugging.show_test_result_async(page, success, message='', delay_ms=3000)[source]
Show test result banner (PASS/FAIL) and wait (async version).
- Return type:
- scitex_browser.debugging.setup_console_interceptor(page)[source]
Set up console log interceptor with source tracking and error capture.
Features (mirroring console-interceptor.ts): - Intercepts console.log, info, warn, error, debug - Captures source file and line number - Captures unhandled JS errors - Captures unhandled promise rejections - Captures resource loading failures
Call this at the start of each test to begin capturing logs.
- Return type:
- scitex_browser.debugging.collect_console_logs(page)[source]
Collect all captured console logs from the browser.
- Return type:
- Returns:
List of log strings in format “[LEVEL] source message”
- scitex_browser.debugging.collect_console_logs_detailed(page)[source]
Collect all captured console logs with full details.
- Returns:
level, message, source, timestamp, url
- Return type:
List of dicts with keys
- scitex_browser.debugging.format_logs_devtools_style(logs)[source]
Format logs in DevTools-like style.
- scitex_browser.debugging.save_failure_artifacts(page, test_name, artifacts_dir, console_logs=None)[source]
Save screenshot, console logs, and page HTML on test failure.
- Parameters:
- Return type:
- Returns:
Dict with paths to saved artifacts
- scitex_browser.debugging.create_failure_capture_fixture(artifacts_dir)[source]
Create a pytest fixture for automatic failure capture.
- Usage in conftest.py:
from scitex_browser.debugging import create_failure_capture_fixture
- capture_on_failure = create_failure_capture_fixture(
Path(__file__).parent / “artifacts”
)
- async scitex_browser.debugging.capture_debug_artifacts_async(page, label, base_dir=None, *, full_page=True, include_html=True)[source]
Save a screenshot and (optionally) the page HTML.
- Parameters:
page (playwright.async_api.Page) – Live page object.
label (str) – Short tag used as the filename prefix (e.g. “mfa_picker_before”). Sanitized: non-alphanum chars become “_”.
base_dir (path-like or None) – Where to write. Defaults to
$SCITEX_DIR/browser/runtime/cache/debug/(~/.scitex/browser/runtime/cache/debug/by default).full_page (bool) – Capture the full scrollable page (default True). Pass False for viewport-only.
include_html (bool) – Save
page.content()alongside the screenshot (default True).
- Returns:
Paths actually written, or None on failure.
- Return type:
(png_path, html_path)
- class scitex_browser.debugging.TestMonitor(output_dir=None, interval=2.0, quality=70, verbose=False, test_name=None)[source]
Bases:
objectMonitor E2E tests with periodic screenshots using scitex.capture.
Captures screenshots at regular intervals during test execution, allowing visual inspection of test progress and debugging.
- __init__(output_dir=None, interval=2.0, quality=70, verbose=False, test_name=None)[source]
Initialize test monitor.
- Parameters:
output_dir (
str|Path) – Directory for screenshots (default: $SCITEX_DIR/browser/runtime/test_monitor)interval (
float) – Seconds between screenshots (default: 2.0)quality (
int) – JPEG quality 1-100 (default: 70)verbose (
bool) – Print capture messagestest_name (
str) – Optional test name for session identification
- scitex_browser.debugging.create_test_monitor_fixture(output_dir=None, interval=2.0, auto_gif=False)[source]
Create a pytest fixture for test monitoring.
- Usage in conftest.py:
from scitex_browser.debugging import create_test_monitor_fixture
test_monitor = create_test_monitor_fixture(interval=2.0, auto_gif=True)
- scitex_browser.debugging.monitor_test(test_func=None, interval=2.0, auto_gif=False)[source]
Decorator for monitoring tests with periodic screenshots.
- Usage:
@monitor_test(interval=1.0, auto_gif=True) def test_my_feature(page):
# test code…
- class scitex_browser.debugging.SyncBrowserSession(page, timeout=60, on_enter=None, on_exit=None)[source]
Bases:
objectSync context manager for playwright browser sessions.
Ensures zombie process cleanup on test failures, timeouts, or crashes. Tracks browser PIDs and kills orphaned processes on exit.
- __init__(page, timeout=60, on_enter=None, on_exit=None)[source]
Initialize sync browser session.
- Parameters:
page (
Page) – Playwright page instance from pytest-playwrighttimeout (
int) – Default timeout for operations in secondson_enter (
Optional[Callable[[Page],None]]) – Callback when entering contexton_exit (
Optional[Callable[[Page,bool],None]]) – Callback when exiting context (receives page and success flag)
- scitex_browser.debugging.sync_browser_session(page, timeout=60, on_enter=None, on_exit=None)[source]
Context manager for sync playwright sessions.
- Usage:
- with sync_browser_session(page) as session:
session.page.goto(url) # … test code
# Cleanup happens automatically
- scitex_browser.debugging.create_browser_session_fixture(timeout=60, setup=None, teardown=None, kill_zombies_on_start=True)[source]
Create a pytest fixture for browser session with cleanup.
- Usage in conftest.py:
from scitex_browser import create_browser_session_fixture
- browser_session = create_browser_session_fixture(
timeout=60, setup=lambda page: print(f”Starting test”), teardown=lambda page, success: print(f”Test {‘passed’ if success else ‘failed’}”), kill_zombies_on_start=True,
)
- Parameters:
- Returns:
A pytest fixture function