Getting Started
Get up and running with the Playwright C# Agentic Framework in minutes. This guide covers installation, configuration, and writing your first test.
Prerequisites
Before you begin, ensure you have:
- .NET SDK 9.0+ – Download from dotnet.microsoft.com
- Playwright browsers – Installed automatically during setup
- Allure CLI (optional, for reporting) –
brew install allureon macOS
Verify your .NET installation:
dotnet --version
# Should output 9.0 or higher
Installation
1. Clone and Restore
Clone the repository from GitHub:
2. Build the Solution
This builds all projects:
Framework/– Core test frameworkAgents/– Healing agents console appTests.E2E/– SpecFlow test project
3. Install Playwright Browsers
Install browsers for the test project:
Install browsers for the Agents project:
Configuration
App Settings
Configure your test environment in Tests.E2E/Support/appsettings.json:
{
"BaseUrl": "https://www.saucedemo.com/",
"DefaultUserEmail": "standard_user",
"DefaultUserPassword": "secret_sauce",
"Headless": true
}
Environment-Specific Settings
Create environment-specific configuration files:
appsettings.qa.json:
{
"BaseUrl": "https://qa.example.com/",
"DefaultUserEmail": "qa_user",
"DefaultUserPassword": "qa_password",
"Headless": true
}
appsettings.staging.json:
{
"BaseUrl": "https://staging.example.com/",
"DefaultUserEmail": "staging_user",
"DefaultUserPassword": "staging_password",
"Headless": true
}
Run tests with a specific environment:
Timeouts
Default timeouts are set to ~5 seconds in LifecycleHooks. Override via environment variable:
Your First Test
1. Create a Feature File
Create Tests.E2E/Features/Login.feature:
Feature: User Login
As a user
I want to log in to the application
So that I can access my account
Scenario: Successful login with valid credentials
Given I navigate to the login page
When I enter email "standard_user" and password "secret_sauce"
And I click the login button
Then I should be redirected to the dashboard
2. Implement Step Definitions
Create Tests.E2E/Steps/LoginSteps.cs:
using Framework.Pages;
using Framework.Support;
using TechTalk.SpecFlow;
namespace Tests.E2E.Steps;
[Binding]
public class LoginSteps
{
private readonly LoginPage _loginPage;
private readonly ScenarioContext _scenarioContext;
public LoginSteps(LoginPage loginPage, ScenarioContext scenarioContext)
{
_loginPage = loginPage;
_scenarioContext = scenarioContext;
}
[Given(@"I navigate to the login page")]
public void GivenINavigateToTheLoginPage()
{
_loginPage.Navigate();
}
[When(@"I enter email ""(.*)"" and password ""(.*)""")]
public void WhenIEnterEmailAndPassword(string email, string password)
{
_loginPage.EnterEmail(email);
_loginPage.EnterPassword(password);
}
[When(@"I click the login button")]
public void WhenIClickTheLoginButton()
{
_loginPage.ClickLogin();
}
[Then(@"I should be redirected to the dashboard")]
public void ThenIShouldBeRedirectedToTheDashboard()
{
_loginPage.WaitForDashboard();
Assert.True(_loginPage.IsOnDashboard());
}
}
3. Create a Page Object
Create Framework/Pages/LoginPage.cs:
using Framework.Support;
using Microsoft.Playwright;
namespace Framework.Pages;
public class LoginPage : BasePage
{
public LoginPage(IPage page, Configuration config) : base(page, config)
{
}
private ILocator EmailInput => Page.Locator("#user-name");
private ILocator PasswordInput => Page.Locator("#password");
private ILocator LoginButton => Page.Locator("#login-button");
private ILocator Dashboard => Page.Locator(".inventory_container");
public async Task Navigate()
{
await Page.GotoAsync(Config.BaseUrl);
}
public async Task EnterEmail(string email)
{
await EmailInput.FillAsync(email);
}
public async Task EnterPassword(string password)
{
await PasswordInput.FillAsync(password);
}
public async Task ClickLogin()
{
await LoginButton.ClickAsync();
}
public async Task WaitForDashboard()
{
await Dashboard.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible });
}
public bool IsOnDashboard()
{
return Dashboard.IsVisibleAsync().Result;
}
}
4. Run Your Test
Learning Selectors (First Time Setup)
Before using the healing feature, you need to build the selector registry. Run your tests on a green suite:
This creates agents/selectors.registry.json with multiple locator strategies for each element, which the Healer uses for auto-repair.
- Learn about the Healing Engine to understand auto-repair
- Explore Running Tests for parallel execution and filtering
- Set up Reporting with Allure
- Configure CI/CD integration