sdk/loadtestservice/Azure.Developer.Playwright.MSTest/README.md
Azure Playwright is a fully managed service that uses the cloud to enable you to run Playwright tests with much higher parallelization across different operating system-browser combinations simultaneously. This means faster test runs with broader scenario coverage, which helps speed up delivery of features without sacrificing quality. With Azure Playwright, you can release features faster and more confidently.
Ready to get started? Jump into our quickstart guide!
Install the client library for .NET with NuGet:
dotnet add package Azure.Developer.Playwright.MSTest --prerelease
To learn more about options for Microsoft Entra Id authentication, refer to Azure.Identity credentials.
Sign in to the Azure portal with your Azure account.
Create the Workspace.
Select the menu button in the upper-left corner of the portal, and then select Create a resource.
Enter Playwright Workspaces in the search box.
Select the Playwright Workspaces card, and then select Create.
Provide the following information to configure a new Playwright workspace:
| Field | Description |
|---|---|
| Subscription | Select the Azure subscription that you want to use for this Playwright workspace. |
| Resource group | Select an existing resource group. Or select Create new, and then enter a unique name for the new resource group. |
| Name | Enter a unique name to identify your workspace. |
The name can only consist of alphanumerical characters, and have a length between 3 and 64 characters. | | Location | Select a geographic location to host your workspace. This location also determines where the test execution results are stored. |
> [!NOTE]
> Optionally, you can configure more details on the **Tags** tab. Tags are name/value pairs that enable you to categorize resources and view consolidated billing by applying the same tag to multiple resources and resource groups.
After you're finished configuring the resource, select Review + Create.
Review all the configuration settings and select Create to start the deployment of the Playwright workspace.
When the process has finished, a deployment success message appears.
To view the new workspace, select Go to resource.
```
Create a file PlaywrightServiceSetup.cs in the root directory with the below content
using System.Threading.Tasks;
using Azure.Developer.Playwright.MSTest;
using Azure.Identity;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PlaywrightService.SampleTests; // Remember to change this as per your project namespace
public class PlaywrightServiceMSTestSetup
{
private static PlaywrightServiceBrowserMSTest playwrightClient = null!;
[AssemblyInitialize]
public static async Task AssemblyInitialize(TestContext testContext)
{
playwrightClient = new PlaywrightServiceBrowserMSTest(context: testContext, credential: new DefaultAzureCredential());
await playwrightClient.InitializeAsync();
}
[AssemblyCleanup]
public static async Task AssemblyCleanup()
{
await playwrightClient.DisposeAsync();
}
}
[!NOTE] Make sure your project uses
Microsoft.Playwright.MSTestversion 1.37 or above.
In the Playwright portal, copy the command under Add region endpoint in your set up.
The endpoint URL corresponds to the workspace region. You might see a different endpoint URL in the Playwright portal, depending on the region you selected when creating the workspace.
Ensure that the PLAYWRIGHT_SERVICE_URL that you obtained in previous step is available in your environment.
Run Playwright tests against browsers managed by the service using the configuration you created above.
dotnet test
Key concepts of the Azure Playwright MSTest SDK for .NET can be found here
Code samples for using this SDK can be found in the following locations
Run tests in a CI/CD pipeline.
Learn how to manage access to the created workspace.
Experiment with different number of workers to determine the optimal configuration of your test suite.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla].
This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [[email protected]][coc_contact] with any additional questions or comments.