OneStreamAutoLibrary.PlaywrightHelpers
2026.4.12.1
dotnet add package OneStreamAutoLibrary.PlaywrightHelpers --version 2026.4.12.1
NuGet\Install-Package OneStreamAutoLibrary.PlaywrightHelpers -Version 2026.4.12.1
<PackageReference Include="OneStreamAutoLibrary.PlaywrightHelpers" Version="2026.4.12.1" />
<PackageVersion Include="OneStreamAutoLibrary.PlaywrightHelpers" Version="2026.4.12.1" />
<PackageReference Include="OneStreamAutoLibrary.PlaywrightHelpers" />
paket add OneStreamAutoLibrary.PlaywrightHelpers --version 2026.4.12.1
#r "nuget: OneStreamAutoLibrary.PlaywrightHelpers, 2026.4.12.1"
#:package OneStreamAutoLibrary.PlaywrightHelpers@2026.4.12.1
#addin nuget:?package=OneStreamAutoLibrary.PlaywrightHelpers&version=2026.4.12.1
#tool nuget:?package=OneStreamAutoLibrary.PlaywrightHelpers&version=2026.4.12.1
PlaywrightHelpers
A helper library for Playwright-based UI automation in .NET. It provides reusable browser setup, configuration access, wait helpers, page interaction utilities, and screenshot capture for Playwright test projects.
Integration
PlaywrightHelpers is designed to be used by:
- Web and UI test projects using xUnit and Playwright
- Shared automation frameworks that need consistent browser, page, and configuration helpers
- CI pipelines that run Playwright tests with environment-variable-based configuration
Features
- Browser bootstrapping with support for Chromium, Firefox, WebKit, and Edge channel
- Centralized configuration via
Config/TestExecutionConfig.jsonand environment variables - Config file discovery from the current working directory or parent folders
- Base URL, browser, headless, slow motion, run mode, and BrowserStack settings accessors
- Shared Playwright base methods for waits, page state checks, frame/window switching, and interactions
- Screenshot capture with timestamped file naming and automatic screenshot directory creation
Project Structure
Browser.cs- Creates and configures Playwright browser, context, and page instancesPlaywrightBase.cs- Shared wait, page-state, and interaction helper methods for derived classesPlaywrightConfig.cs- Configuration accessors for execution settings, base URL, and remote execution valuesScreenCaptureLibrary.cs- Screenshot capture and path management utilities
Configuration
Configuration is loaded from:
Config/TestExecutionConfig.json- Environment variables, which override JSON values
PlaywrightConfig resolves the config file by checking the current directory, the application base directory, and then parent folders until it finds Config/TestExecutionConfig.json.
Common TestExecutionDetails keys
BrowserEnvironmentBaseUrlHeadlessSlowMoRunModeBuildNameMaxArchiveDaysPlaywrightConnectionUrl
Common configuration methods
GetBrowserFromConfigFile()GetEnvironmentFromConfigFile()GetBaseUrl()GetHeadlessFromConfigFile()GetHeadlessMode()GetSlowMoFromConfigFile()GetRunMode()GetBuildName()EnvironmentInfo()BrowserStackCapabilities()
Sample TestExecutionConfig.json
{
"TestExecutionDetails": {
"Browser": "Chromium",
"Environment": "QA",
"BaseUrl": "https://qa.example.com",
"Headless": "true",
"SlowMo": "0",
"RunMode": "Local",
"BuildName": "Playwright Smoke Tests",
"MaxArchiveDays": "30",
"PlaywrightConnectionUrl": "wss://cdp.example.com/playwright"
},
"Environments": {
"QA": {
"BaseUrl": "https://qa.example.com"
},
"Dev": {
"BaseUrl": "https://dev.example.com"
}
},
"Users": {
"TestUser1": {
"Username": "test.user@example.com",
"Password": "use-secure-secret-storage"
}
},
"BrowserStack": {
"User": "BrowserStackUser1",
"DeviceName": "iPhone 15",
"OperatingSystem": "Windows",
"OSVersion": "11",
"Orientation": "portrait"
},
"BrowserCapabilities": {
"Chromium": {
"browserName": "chromium",
"browserVersion": "latest"
},
"Firefox": {
"browserName": "firefox",
"browserVersion": "latest"
}
}
}
Quick Start
using Microsoft.Playwright;
using PlaywrightHelpers;
public class ExampleTest
{
public async Task RunAsync()
{
using var playwright = await Playwright.CreateAsync();
var (browser, context, page) = await Browser.CreateBrowserAsync(playwright);
try
{
await page.GotoAsync(PlaywrightConfig.GetBaseUrl());
var capture = new ScreenCaptureLibrary(page);
await capture.Capture("example-home");
}
finally
{
await context.CloseAsync();
await browser.CloseAsync();
}
}
}
Browser Setup
Browser.CreateBrowserAsync() uses the current configuration to:
- select Chromium, Firefox, WebKit, or Edge
- apply headless mode
- apply slow motion delay
- open a maximized browser context with no fixed viewport
Base Helpers
PlaywrightBase includes reusable helpers for common automation flows, such as:
WaitUntilElementExists()WaitUntilElementVisible()WaitUntilElementInvisible()WaitUntilPageLoaded()WaitUntilPageHasTitle()SwitchToFrame()SwitchToWindow()Click()InputText()
Screenshot Capture
ScreenCaptureLibrary captures full-page screenshots and stores them in a Screenshots folder under the solution root using a timestamped .png file name.
var capture = new ScreenCaptureLibrary(page);
await capture.Capture("login-page");
Notes
- Keep secrets such as BrowserStack credentials in environment variables or secure pipeline secrets.
GetBaseUrl()throws an exception whenBaseUrlis not configured, which helps catch invalid test setup early.- Prefer environment-specific values in
Config/TestExecutionConfig.jsonfor predictable local and CI behavior.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration (>= 9.0.11)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.11)
- Microsoft.Extensions.Configuration.FileExtensions (>= 9.0.11)
- Microsoft.Extensions.Configuration.Json (>= 9.0.11)
- Microsoft.Playwright (>= 1.59.0)
-
net8.0
- Microsoft.Extensions.Configuration (>= 9.0.11)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.11)
- Microsoft.Extensions.Configuration.FileExtensions (>= 9.0.11)
- Microsoft.Extensions.Configuration.Json (>= 9.0.11)
- Microsoft.Playwright (>= 1.59.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|