microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.48k stars 236 forks source link

[Feature]: Automatically install browsers in .NET test projects #2995

Closed LarsKemmann closed 1 month ago

LarsKemmann commented 1 month ago

🚀 Feature Request

Show how to add something like the following to the .NET project files, like the NUnit Playwright template:

  <!-- Automatically install required browsers for Playwright. -->
  <Target Name="PostBuild" AfterTargets="Build" Condition="'$(TF_BUILD)' != 'True'">
    <Exec Command="pwsh bin/Debug/$(TargetFramework)/playwright.ps1 install" />
  </Target>

Example

This removes one extra step for people who are developing locally. It does make some assumptions about a person's workflow, so it's probably best not to add it to the actual project template files, but including it as guidance (e.g., commented out inside the project file as a suggestion) could be useful.

Motivation

Automatically installing the required browsers could be a nice quality-of-life improvement for teams -- every new machine setup, every new team member, always has to go through the failed test and figure out that they need to run a command, then figure out in which directory to run the command, etc.

mxschmitt commented 1 month ago

Looks like we can fold that into https://github.com/microsoft/playwright-dotnet/issues/2286. You can also do something like that during runtime, there you exactly know which browsers you want to run.

mxschmitt commented 1 month ago

Folding into https://github.com/microsoft/playwright-dotnet/issues/2286