Example and Demo of how to use PlayWright with dotnet, GitHub Actions and Azure DevOps Pipelines
Clone the repo to your favourite folder, and while you're at it, use also your favourite IDE or Code Editor to open the solution.
The Playwight tests in this solution can be found under the Playwright Project.
Extra code Infrastructure/BlazorTest.cs
was added to stub the HTTP Client and run the tests without using a real HTTP Client, this is not part of the bundle that comes with playwright.
If you don't have it yet or want to upgrade your .Net version, Download .Net might be a good place to start alternatively you can also use Install .Net on Windows, Linux and MacOS
Run the solution to see how it looks or go directly to the tests.
You might use the "Run and Debug" option to run the solution to see how it looks or go directly to the tests.
Alternatively you can run dotnet run
from the terminal and if you want to develop while coding, dotnet watch run
might be handy.
If you need to install PowerShell to run the codegen, you might want to refer to Install PowerShell on Windows, Linux, and macOS
But wait! Before running Playwright or the codegen, we need to install it first! refer to Playwright's .Net Installation to get you started!
If you never used it before, give it a go! More on what is it and how to run information can be found @ Test Generator
Spin the solution with the IDE, dotnet run
, dotnet watch run
or however you like and spin the codegen!
For this project soemthing along the lines of pwsh ./PlayWithPlayWright/Playwright/bin/Debug/net7.0/playwright.ps1 codegen https://localhost:7201
is what you need...
A sample .runsettings
file was added to get you started, one possible way to use it is to configure Visual Studio to use the settings file, the other is when running your tests in the command line: More information @ Configure unit tests by using a .runsettings file for Visual Studio and dotnet test for the CLI.
If you're like me, and I know I am, you just want to try it, so, this should work dotnet test --settings ./PlayWithPlayWright/Playwright/.runsettings
You can use the settings file, for instance, to slow down the test runner by changing the SlowMo
value or if you want to see the "magic happening" turn off the headless mode, also helpfull for debugging by setting healess
to false
;