Add webwright doctor setup validation command#23
Conversation
|
@microsoft-github-policy-service agree |
|
@adamlu123 @microsoftopensource could you please look into this pr |
There was a problem hiding this comment.
Pull request overview
Adds a new webwright doctor CLI command intended to validate local environment setup and print actionable guidance, alongside broad formatting/line-wrapping changes across the codebase.
Changes:
- Introduce
src/webwright/run/doctor.pywith a Rich table “doctor” check suite (Python/Playwright/Chromium/screenshot/API key/plugin manifests). - Wire the new command into the Typer CLI (
webwright doctor). - Apply widespread formatting-only refactors (mostly line wrapping) across tools/models/environments/agents and update/add unit tests.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_tool_model_routing.py | Formatting-only changes in unit tests. |
| tests/unit/test_doctor.py | Adds unit tests for doctor checks (currently environment-dependent; needs tightening). |
| src/webwright/utils/serialize.py | Formatting-only change (line wrapping). |
| src/webwright/utils/runtime.py | Formatting-only change (line wrapping). |
| src/webwright/utils/logging.py | Formatting-only change (function signature wrapping). |
| src/webwright/tools/self_reflection.py | Formatting-only changes (wrapping/spacing). |
| src/webwright/tools/persistent_local_browser.py | Formatting-only changes in CLI parser construction. |
| src/webwright/tools/image_qa.py | Formatting-only changes (wrapping/comprehensions). |
| src/webwright/tools/_model_config.py | Formatting-only change (wrapping). |
| src/webwright/run/doctor.py | New: implements doctor checks and Rich output (core feature of PR). |
| src/webwright/run/cli.py | Adds doctor subcommand to Typer CLI. |
| src/webwright/models/openrouter_model.py | Formatting-only changes (wrapping). |
| src/webwright/models/openai_model.py | Removes unused imports + formatting for a helper signature. |
| src/webwright/models/base.py | Formatting-only changes (wrapping). |
| src/webwright/models/anthropic_model.py | Formatting-only changes (wrapping). |
| src/webwright/environments/local_workspace.py | Formatting-only changes (wrapping/comprehensions). |
| src/webwright/environments/local_browser.py | Formatting-only changes (wrapping). |
| src/webwright/environments/init.py | Formatting-only change (wrapping). |
| src/webwright/agents/default.py | Formatting-only changes (wrapping); minor string literal adjustments. |
| src/webwright/agents/init.py | Formatting-only change (wrapping). |
| src/webwright/init.py | Formatting-only changes (blank lines). |
| assets/task_showcase/app.py | Formatting-only changes (wrapping/blank lines). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def test_check_playwright(): | ||
| ok, message = check_playwright() | ||
|
|
||
| assert isinstance(ok, bool) | ||
| assert isinstance(message, str) | ||
|
|
| def test_check_chromium(): | ||
| ok, message = check_chromium() | ||
|
|
||
| assert isinstance(ok, bool) | ||
| assert isinstance(message, str) | ||
|
|
| def test_check_screenshot(): | ||
| ok, message = check_screenshot() | ||
|
|
||
| assert isinstance(ok, bool) | ||
| assert isinstance(message, str) | ||
|
|
| def test_screenshot_file_cleanup(): | ||
| screenshot_path = Path("doctor_test.png") | ||
|
|
||
| if screenshot_path.exists(): | ||
| screenshot_path.unlink() | ||
|
|
||
| check_screenshot() | ||
|
|
||
| assert not screenshot_path.exists() |
| except Exception: | ||
| return False, ( | ||
| "unable to launch Chromium for screenshot validation\n" | ||
| "Fix: playwright install" | ||
| ) |
| result = subprocess.run( | ||
| ["playwright", "install", "--dry-run"], | ||
| capture_output=True, | ||
| text=True, | ||
| ) |
| console.print(table) | ||
|
|
||
| console.print(f"\n{passed}/{len(CHECKS)} checks passed") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_doctor() |
| @app.command() | ||
| def doctor(): | ||
| """ | ||
| Validate local Webwright setup. | ||
| """ | ||
| run_doctor() | ||
|
|
|
@subramanya-dev Thanks for the pr. Could you split the unrelated format changes with the doctor? so that after the split, this |
- add environment validation checks
- add screenshot runtime validation
- improve onboarding diagnostics
- add doctor CLI command
- add automated tests
29784e0 to
6f67dde
Compare
|
@adamlu123 Thanks for the review. I've split out the unrelated formatting changes. This PR now contains only the doctor implementation ( |

Adds a
webwright doctorCLI command to validate local environment setup and provide actionable fixes for common onboarding and runtime issues.Features
Motivation
Webwright setup currently requires multiple manual steps, and configuration issues are often discovered only during runtime with limited debugging guidance.
This command helps users validate their environment before running tasks and improves the onboarding and debugging experience.
Testing
All tests passing.