I've written a Playwright test but instead of running it via the test runner (NUnit), I'd like to run my Playwright code either from a console application or an ASP.NET Core background service.
What is the easiest way to setup Playwright so that it can be run without a test runner?
This is my current console app code:
using Microsoft.Playwright;
var browserTest = new Microsoft.Playwright.NUnit.BrowserTest();
var context = await browserTest.NewContext();
var page = await context.NewPageAsync();
await page.SetViewportSizeAsync(600,800);
await page.GotoAsync("https://www.google.com/");
...raising a NullReferenceException
for await browserTest.NewContext();
.
I'm using:
- .NET 7
- Chromium browser
- OS: Linux (Docker)