Skip to content

Add webwright doctor setup validation command#23

Open
subramanya-dev wants to merge 1 commit into
microsoft:mainfrom
subramanya-dev:feature/onboarding-validation-command
Open

Add webwright doctor setup validation command#23
subramanya-dev wants to merge 1 commit into
microsoft:mainfrom
subramanya-dev:feature/onboarding-validation-command

Conversation

@subramanya-dev
Copy link
Copy Markdown

Screenshot 2026-05-28 at 10 02 15 PM ## Summary

Adds a webwright doctor CLI command to validate local environment setup and provide actionable fixes for common onboarding and runtime issues.

Features

  • Python version validation
  • Playwright installation check
  • Chromium availability check
  • Screenshot runtime validation
  • API key validation
  • Plugin manifest validation
  • Rich table CLI output
  • Automated test coverage

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

pytest tests/unit/test_doctor.py

All tests passing.

@subramanya-dev
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@subramanya-dev
Copy link
Copy Markdown
Author

Improve doctor runtime validation and reliability

  • lazy load Playwright imports
  • remove external network dependency from screenshot validation
Screenshot 2026-05-28 at 10 02 15 PM
  • improve Chromium launch validation
  • add safer screenshot cleanup
  • refine onboarding diagnostics and fix suggestions
  • improve doctor command reliability in CI/offline environments

@subramanya-dev
Copy link
Copy Markdown
Author

@adamlu123 @microsoftopensource could you please look into this pr

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py with 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.

Comment thread tests/unit/test_doctor.py
Comment on lines +20 to +25
def test_check_playwright():
ok, message = check_playwright()

assert isinstance(ok, bool)
assert isinstance(message, str)

Comment thread tests/unit/test_doctor.py
Comment on lines +27 to +32
def test_check_chromium():
ok, message = check_chromium()

assert isinstance(ok, bool)
assert isinstance(message, str)

Comment thread tests/unit/test_doctor.py
Comment on lines +34 to +39
def test_check_screenshot():
ok, message = check_screenshot()

assert isinstance(ok, bool)
assert isinstance(message, str)

Comment thread tests/unit/test_doctor.py
Comment on lines +86 to +94
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()
Comment on lines +71 to +75
except Exception:
return False, (
"unable to launch Chromium for screenshot validation\n"
"Fix: playwright install"
)
Comment on lines +32 to +36
result = subprocess.run(
["playwright", "install", "--dry-run"],
capture_output=True,
text=True,
)
Comment on lines +141 to +147
console.print(table)

console.print(f"\n{passed}/{len(CHECKS)} checks passed")


if __name__ == "__main__":
run_doctor()
Comment thread src/webwright/run/cli.py
Comment on lines +166 to +172
@app.command()
def doctor():
"""
Validate local Webwright setup.
"""
run_doctor()

@adamlu123
Copy link
Copy Markdown
Contributor

adamlu123 commented May 29, 2026

@subramanya-dev Thanks for the pr. Could you split the unrelated format changes with the doctor? so that after the split, this
PR should be roughly: doctor.py + test_doctor.py + the cli.py wiring

    - add environment validation checks
    - add screenshot runtime validation
    - improve onboarding diagnostics
    - add doctor CLI command
    - add automated tests
@subramanya-dev subramanya-dev force-pushed the feature/onboarding-validation-command branch from 29784e0 to 6f67dde Compare May 30, 2026 02:18
@subramanya-dev
Copy link
Copy Markdown
Author

@adamlu123 Thanks for the review. I've split out the unrelated formatting changes. This PR now contains only the doctor implementation (doctor.py), its tests (test_doctor.py) and the required CLI wiring in cli.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants