Show / Hide Table of Contents

Azure Playwright NUnit client library for .NET

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. The service also enables you to publish test results and related artifacts to the service and view them in the service portal enabling faster and easier troubleshooting. With Azure Playwright, you can release features faster and more confidently.

Ready to get started? Jump into our quickstart guide!

Useful links

  • Quickstart: Run end-to-end tests at scale
  • View Azure Playwright service demo
  • Documentation
  • Pricing
  • Share feedback

Getting started

Install the package

Install the client library for .NET with NuGet:

dotnet add package Azure.Developer.Playwright.NUnit --prerelease

Prerequisites

  • An Azure subscription
  • Your Azure account must be assigned the Owner, Contributor, or one of the classic administrator roles.

Authenticate the client

To learn more about options for Microsoft Entra Id authentication, refer to Azure.Identity credentials.

Create a Workspace

  1. Sign in to the Playwright portal with your Azure account.

  2. Create the Workspace

    Create new workspace

    Field Description
    Workspace Name A unique name to identify your workspace.
    The name can't contain special characters or whitespace.
    Azure Subscription Select an Azure subscription where you want to create the workspace.
    Region This is where test run data will be stored for your workspace.
Note

If you don't see this screen, select an existing workspace and go to the next section.

```

Set up Azure Playwright

Create a file PlaywrightServiceSetup.cs in the root directory with the below content

using Azure.Developer.Playwright.NUnit;
using Azure.Identity;

namespace PlaywrightService.SampleTests; // Remember to change this as per your project namespace

[SetUpFixture]
public class PlaywrightServiceNUnitSetup : PlaywrightServiceBrowserNUnit { }
Note

Make sure your project uses Microsoft.Playwright.NUnit version 1.37 or above.

Obtain region endpoint

  1. In the Playwright portal, copy the command under Add region endpoint in your set up.

    Set workspace endpoint

    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.

Set up environment

Ensure that the PLAYWRIGHT_SERVICE_URL that you obtained in previous step is available in your environment.

Run the tests

Run Playwright tests against browsers managed by the service using the configuration you created above.

dotnet test

Key concepts

Key concepts of the Azure Playwright NUnit SDK for .NET can be found here

Examples

Code samples for using this SDK can be found in the following locations

  • .NET Azure Playwright NUnit Library Code Samples

Troubleshooting

  • File an issue via GitHub Issues.
  • Check previous questions or ask new ones on Stack Overflow using Azure and .NET tags.

Next steps

  • 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.

Contributing

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 [opencode@microsoft.com][coc_contact] with any additional questions or comments.

Impressions

Back to top Azure SDK for .NET