Skip to content

feat(program): add RunWithResult for capturing driver output#3308

Merged
dgozman merged 1 commit intomicrosoft:mainfrom
dgozman:fix-3139
May 1, 2026
Merged

feat(program): add RunWithResult for capturing driver output#3308
dgozman merged 1 commit intomicrosoft:mainfrom
dgozman:fix-3139

Conversation

@dgozman
Copy link
Copy Markdown
Collaborator

@dgozman dgozman commented May 1, 2026

Summary

  • Adds Microsoft.Playwright.Program.RunWithResult(string[] args) which runs the Playwright driver with stdout/stderr redirected (instead of inherited) and returns a Program.RunResult { ExitCode, StandardOutput, StandardError }.
  • Useful under test frameworks like xUnit that don't surface inherited console output, where the existing Run only returns an exit code and the diagnostic message is lost.
  • Existing Run and Main are unchanged; the shared driver-process construction (path lookup, arg quoting, env vars) is extracted into a private helper.

Fixes #3139

Adds Program.RunWithResult, which runs the driver without inheriting
the calling process's stdio and returns a RunResult { ExitCode,
StandardOutput, StandardError }. Useful under test frameworks (e.g.
xUnit) that don't surface inherited console output, where a non-zero
Run() exit code is otherwise undiagnosable. Run() is unchanged.

References microsoft#3139
@dgozman dgozman merged commit a538db1 into microsoft:main May 1, 2026
16 checks passed
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.

[Feature]: Add possibility to diagnose errors when Microsoft.Playwright.Program.Run() fails

2 participants