4.azure Playwright Testing
4.azure Playwright Testing
e OVERVIEW
Get started
f QUICKSTART
p CONCEPT
Manage workspaces
c HOW-TO GUIDE
Manage workspaces
Security
c HOW-TO GUIDE
Manage authentication
What is Microsoft Playwright Testing
Preview?
Article • 09/16/2024
Microsoft Playwright Testing Preview is a fully managed service for end-to-end testing
built on top of Playwright. With Playwright, you can automate end-to-end tests to
ensure your web applications work the way you expect it to, across different web
browsers and operating systems. The service abstracts the complexity and infrastructure
for running Playwright tests and managing results and artifacts. The service runs tests
with high parallelization and stores test results and artifacts to help you ship features
faster and troubleshoot easily.
Run your Playwright test suite in the cloud, without changes to your test code or
modifications to your tooling setup. Use the Playwright Test Visual Studio Code
extension for a rich editor experience, or use the Playwright CLI to add automation
within your continuous integration (CI) workflow.
Get started with Quickstart: run your Playwright tests at scale with Microsoft Playwright
Testing.
To learn more about how to create end-to-end tests with the Playwright framework, visit
the Getting started documentation on the Playwright website.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Distribute your tests across many parallel browsers, hosted on cloud infrastructure.
Scale your tests beyond the processing power of your developer workstation, local
infrastructure, or CI agent machines.
Consistent regional performance by running your tests on browsers in an Azure
region that's closest to your client machine.
Learn more about how you can configure for optimal performance.
Run tests simultaneously across all modern browsers on Windows, Linux, and
mobile emulation of Google Chrome for Android and Mobile Safari.
Using service-managed browsers ensures consistent and reliable results for both
functional and visual regression testing, whether tests are run from your team's
developer workstations or CI pipeline.
Publish test results and artifacts to the service and view them in the service portal
for faster troubleshooting.
Integrate reporting with CI pipelines to get rich, consolidated reports.
Endpoint testing
Use cloud-hosted remote browsers to test web applications regardless of where they're
hosted, without having to allow inbound connections on your firewall.
During the development phase, run tests against a localhost development server.
Playwright support
Microsoft Playwright Testing is built on top of the Playwright framework.
Support for multiple versions of Playwright with each new Playwright release.
Integrate your existing Playwright test suite without changing your test code.
Use the Playwright Test Visual Studio Code extension for a rich editor experience.
How it works
Microsoft Playwright Testing instantiates cloud-hosted browsers across different
operating systems. Playwright runs on the client machine and interacts with Microsoft
Playwright Testing to run your Playwright tests on the hosted browsers. The client
machine can be your developer workstation or a CI agent machine if you run your tests
as part of your CI workflow. The Playwright test code remains on the client machine
during the test run.
After a test run completes, the test results, trace files, and other test run files are
available on the client machine. These are then published to the service from the client
machine and can be viewed in the service portal.
To run existing tests with Microsoft Playwright Testing requires no changes to your test
code, install the Microsoft Playwright Testing service package and specify the service
endpoint for your workspace.
Learn more about how to determine the optimal configuration for optimizing test suite
completion.
Microsoft Playwright Testing automatically encrypts all data stored in your workspace
with keys managed by Microsoft (service-managed keys). For example, this data includes
workspace details, Playwright test run meta data like test start and end time, test
minutes, who ran the test, and test results and artifacts generated by Playwright which
are published to the service.
Next step
Quickstart: Run Playwright tests at scale
Feedback
Was this page helpful? Yes No
Microsoft Playwright Testing Preview is a fully managed service for end-to-end testing
built on top of Playwright. With the free trial, you can try Microsoft Playwright Testing
for free for 30 days, 100 test minutes, and 1,000 test results. In this article, you learn
about the limits of the free trial, how to get started, and how to track your free trial
usage.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Prerequisites
An Azure account with an active subscription. If you don't have an Azure
subscription, create a free account before you begin.
Your Azure account needs the Owner, Contributor, or one of the classic
administrator roles.
ノ Expand table
Resource Limit
Number of workspaces²³ 1
¹ If your usage exceeds either the free test minute limit or the free test result limit, only
the overage counts toward the pay-as-you-go billing model. The two features are billed
separately. See Microsoft Playwright Testing preview pricing
² These limits only apply to the first workspace you create in your Azure subscription.
Any subsequent workspaces you create in the subscription automatically uses the pay-
as-you-go billing model.
³ If you delete the free trial workspace, you can't create a new free trial workspace
anymore.
U Caution
If you exceed any of these limits, the workspace is automatically converted to the
pay-as-you-go billing model. Learn more about the Microsoft Playwright Testing
pricing .
Create a workspace
The first time you create a workspace in your Azure subscription, the workspace is
automatically enrolled in the free trial.
If this is the first workspace you create in the Azure subscription, you see a
message that the workspace is eligible for the free trial.
ノ Expand table
Field Description
Azure Select the Azure subscription that you want to use for this Microsoft
subscription Playwright Testing workspace.
In the list of all workspaces, you can view a banner message that indicates if a
workspace is in the free trial.
All test runs, test results, and other artifacts linked to your workspace remain available.
Next step
Quickstart: Run Playwright tests at scale
Feedback
Was this page helpful? Yes No
In this quickstart, you learn how to run your Playwright tests with highly parallel cloud
browsers and troubleshoot failed tests easily using Microsoft Playwright Testing Preview.
Use cloud infrastructure to validate your application across multiple browsers, devices,
and operating systems. Publish the results and artifacts generated by Playwright to the
service and view them in the service portal.
After you complete this quickstart, you have a Microsoft Playwright Testing workspace
to run your Playwright tests at scale and view test results and artifacts in the service
portal.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Prerequisites
An Azure account with an active subscription. If you don't have an Azure
subscription, create a free account before you begin.
Your Azure account needs the Owner, Contributor, or one of the classic
administrator roles.
A Playwright project. If you don't have project, create one by using the Playwright
getting started documentation or use our Microsoft Playwright Testing sample
project .
Azure CLI. If you don't have Azure CLI, see Install Azure CLI.
Create a workspace
To get started with running your Playwright tests at scale on cloud browsers, you first
create a Microsoft Playwright Testing workspace in the Playwright portal.
1. Sign in to the Playwright portal with your Azure account.
2. If you already have a workspace, select an existing workspace, and move to the
next step.
Tip
3. If you don't have a workspace yet, select + New workspace, and then provide the
following information:
ノ Expand table
Field Description
Azure Select the Azure subscription that you want to use for this Microsoft
subscription Playwright Testing workspace.
When the workspace creation finishes, you're redirected to the setup guide.
npm
If you already have this file, the package asks you to override it.
1. In Add region endpoint in your setup, copy the region endpoint for your
workspace.
The endpoint URL matches the Azure region that you selected when creating the
workspace. Make sure this URL is available in PLAYWRIGHT_SERVICE_URL environment
variable.
We recommend that you use the dotenv module to manage your environment. With
dotenv , you define your environment variables in the .env file.
shell
PLAYWRIGHT_SERVICE_URL={MY-REGION-ENDPOINT}
Make sure to replace the {MY-REGION-ENDPOINT} text placeholder with the value you
copied earlier.
Set up Authentication
To run your Playwright tests in your Microsoft Playwright Testing workspace, you need
to authenticate the Playwright client where you're running the tests with the service. This
could be your local dev machine or CI machine.
The service offers two authentication methods: Microsoft Entra ID and Access Tokens.
Microsoft Entra ID uses your Azure credentials, requiring a sign-in to your Azure account
for secure access. Alternatively, you can generate an access token from your Playwright
workspace and use it in your setup.
Microsoft Entra ID is the default and recommended authentication for the service. From
your local dev machine, you can use Azure CLI to sign-in
CLI
az login
7 Note
If you're a part of multiple Microsoft Entra tenants, make sure you sign in to the
tenant where your workspace belongs. You can get the tenant ID from Azure portal.
See Find your Microsoft Entra Tenant. Once you get the ID, sign-in using the
command az login --tenant <TenantID>
You can generate an access token from your Playwright Testing workspace and use it in
your setup. However, we strongly recommend Microsoft Entra ID for authentication due
to its enhanced security. Access tokens, while convenient, function like long-lived
passwords and are more susceptible to being compromised.
U Caution
TypeScript
use: {
trace: 'on-first-retry',
video:'retain-on-failure',
screenshot:'on'
}
7 Note
Reporting feature is enabled by default for existing workspaces. This is being rolled
out in stages and will take a few days. To avoid failures, confirm that Rich
diagnostics using reporting setting is ON for your workspace before proceeding.
After you validate that the test runs successfully, you can gradually increase the test load
by running more tests with the service.
Perform the following steps to run a single Playwright test with Microsoft Playwright
Testing:
Playwright CLI
To use the Playwright CLI to run your tests with Microsoft Playwright Testing, pass
the service configuration file as a command-line parameter.
2. Enter the following command to run your Playwright test on remote browsers
in your workspace:
Bash
Output
You can now run multiple tests with the service, or run your entire test suite on remote
browsers.
U Caution
Depending on the size of your test suite, you might incur additional charges for the
test minutes and test results beyond your allotted free test minutes and free test
results.
Perform the following steps to run a full Playwright test suite with Microsoft Playwright
Testing:
Playwright CLI
When you run multiple Playwright tests or a full test suite with Microsoft Playwright
Testing, you can optionally specify the number of parallel workers as a command-
line parameter.
2. Enter the following command to run your Playwright test suite on remote
browsers in your workspace:
Bash
Depending on the size of your test suite, this command runs your tests on up
to 20 parallel workers.
After the test completes, you can view the test status in the terminal.
Output
Test report:
https://playwright.microsoft.com/workspaces/<workspace-
id>/runs/<run-id>
1. After your test run completes, a link to the Playwright Portal is generated. Open
this link to view detailed test results and associated artifacts. The portal displays
essential information, including:
CI build details
Overall test run status
The commit ID linked to the test run
2. The Playwright portal provides all the necessary information for troubleshooting.
You can:
3. The Trace Viewer allows you to step through your test execution visually. You can:
Use the timeline to hover over individual steps, revealing the page state
before and after each action.
Inspect detailed logs, DOM snapshots, network activity, errors, and console
output for each step.
Tip
You can use Microsoft Playwright Testing service features independently. You can
publish test results to the portal without using the cloud-hosted browsers feature
and you can also use only cloud-hosted browsers to expedite your test suite
without publishing test results.
7 Note
The test results and artifacts that you publish are retained on the service for 90
days. After that, they are automatically deleted.
With Microsoft Playwright Testing, you can run with up to 50 parallel workers. Several
factors influence the best configuration for your project, such as the CPU, memory, and
network resources of your client machine, the target application's load-handling
capacity, and the type of actions carried out in your tests.
You can specify the number of parallel workers on the Playwright CLI command-line, or
configure the workers property in the Playwright service configuration file.
Learn more about how to determine the optimal configuration for optimizing test suite
completion.
Next step
You've successfully created a Microsoft Playwright Testing workspace in the Playwright
portal and run your Playwright tests on cloud browsers.
Advance to the next quickstart to set up continuous end-to-end testing by running your
Playwright tests in your CI/CD workflow.
Feedback
Was this page helpful? Yes No
In this quickstart, you set up continuous end-to-end testing with Microsoft Playwright
Testing Preview to validate that your web app runs correctly across different browsers
and operating systems with every code commit and troubleshoot tests easily using the
service dashboard. Learn how to add your Playwright tests to a continuous integration
(CI) workflow, such as GitHub Actions, Azure Pipelines, or other CI platforms.
After you complete this quickstart, you have a CI workflow that runs your Playwright test
suite at scale and helps you troubleshoot tests easily with Microsoft Playwright Testing.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Prerequisites
An Azure account with an active subscription. If you don't have an Azure
subscription, create a free account before you begin.
GitHub Actions
A GitHub account. If you don't have a GitHub account, you can create one for
free .
A GitHub repository that contains your Playwright test specifications and
GitHub Actions workflow. To create a repository, see Creating a new
repository .
A GitHub Actions workflow. If you need help with getting started with GitHub
Actions, see create your first workflow
Set up authentication from GitHub Actions to Azure. See Use GitHub Actions
to connect to Azure
To get the service endpoint URL and store it as a CI workflow secret, perform the
following steps:
Tip
3. In Add region endpoint in your setup, copy the service endpoint URL.
The endpoint URL matches the Azure region that you selected when creating the
workspace.
ノ Expand table
TypeScript
However, you can choose to use either of these features or both. See How to use
service features and update the service configuration file as per your requirements.
TypeScript
"devDependencies": {
"@azure/microsoft-playwright-testing": "^1.0.0-beta.6"
}
TypeScript
use: {
trace: 'on-first-retry',
video:'retain-on-failure',
screenshot:'on'
},
Set up authentication
The CI machine running Playwright tests must authenticate with Playwright Testing
service to get the browsers to run the tests and to publish the test results and artifacts.
The service offers two authentication methods: Microsoft Entra ID and Access Tokens.
We strongly recommend using Microsoft Entra ID to authenticate your pipelines.
GitHub Actions
If you're using GitHub Actions, you can connect to the service using GitHub OpenID
Connect. Follow the steps to set up the integration:
Prerequisites
Option 1: Microsoft Entra application
Copy the values for Client ID, Subscription ID, and Directory (tenant) ID to
use later in your GitHub Actions workflow.
Assign the Owner or Contributor role to the service principal created in the
previous step. These roles must be assigned on the Playwright Testing
workspace. For more details, see how to manage access.
Copy the values for Client ID, Subscription ID, and Directory (tenant) ID to
use later in your GitHub Actions workflow.
Add the values you got in the previous step as secrets to your GitHub
repository. See set up GitHub Action Secret. These variables are used in the
GitHub Action workflow in subsequent steps.
ノ Expand table
AZURE_CLIENT_ID Client ID
AZURE_SUBSCRIPTION_ID Subscription ID
U Caution
You can generate an access token from your Playwright Testing workspace and use it in
your setup. However, we strongly recommend Microsoft Entra ID for authentication due
to its enhanced security. Access tokens, while convenient, function like long-lived
passwords and are more susceptible to being compromised.
3. Store the access token in a CI workflow secret and use it in the GitHub Actions
workflow or Azure Pipeline yaml file.
ノ Expand table
The following steps describe the workflow changes for GitHub Actions or Azure
Pipelines. Similarly, you can run your Playwright tests by using the Playwright CLI in
other CI platforms.
GitHub Actions
yml
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
When the CI workflow is triggered, your Playwright tests run in your Microsoft
Playwright Testing workspace on cloud-hosted browsers, across 20 parallel
workers. The results and artifacts collected are published to the service and can be
viewed on service portal.
The settings for your test run can be defined in .runsettings file. For more information,
see how to use service package options
7 Note
Reporting feature is enabled by default for existing workspaces. This is being rolled
out in stages and will take a few days. To avoid failures, confirm that Rich
diagnostics using reporting setting is ON for your workspace before proceeding.
U Caution
With Microsoft Playwright Testing, you get charged based on the number of total
test minutes consumed and test results published. If you're a first-time user or
getting started with a free trial, you might start with running a single test at scale
instead of your full test suite to avoid exhausting your free test minutes and test
results.
After you validate that the test runs successfully, you can gradually increase the test load
by running more tests with the service.
You can run a single test with the service by using the following command-line:
PowerShell
1. After your test run completes, a link to the Playwright Portal is generated. Open
this link to view detailed test results and associated artifacts. The portal displays
essential information, including:
CI build details
Overall test run status
The commit ID linked to the test run
2. The Playwright portal provides all the necessary information for troubleshooting.
You can:
3. The Trace Viewer allows you to step through your test execution visually. You can:
Use the timeline to hover over individual steps, revealing the page state
before and after each action.
Inspect detailed logs, DOM snapshots, network activity, errors, and console
output for each step.
Tip
You can use Microsoft Playwright Testing service features independently. You can
publish test results to the portal without using the cloud-hosted browsers feature
and you can also use only cloud-hosted browsers to expedite your test suite
without publishing test results. For details, see How to use service features.
7 Note
The test results and artifacts that you publish are retained on the service for 90
days. After that, they are automatically deleted.
Related content
You've successfully set up a continuous end-to-end testing workflow to run your
Playwright tests at scale on cloud-hosted browsers.
Feedback
Was this page helpful? Yes No
In this quickstart, you learn how to troubleshoot your Playwright tests easily using
reports and artifacts published on Microsoft Playwright Testing Preview. Additionally,
this guide demonstrates how to utilize the reporting feature, regardless of whether
you're running tests on the cloud-hosted browsers provided by the service.
After you complete this quickstart, you'll have a Microsoft Playwright Testing workspace
to view test results and artifacts in the service portal.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Background
Microsoft Playwright Testing service enables you to:
These two features of the service can be used independently or together, and each has
its own pricing plan . You have the flexibility to:
Expedite test runs and streamline troubleshooting by using both features: running
tests in cloud-hosted browsers and publishing results to the service.
Run tests only in cloud-hosted browsers to finish test runs faster.
Publish test results to the service while continuing to run tests locally for efficient
troubleshooting.
7 Note
This article focuses on how you can publish test results to the service without using
cloud-hosted browsers. If you want to learn how to also accelerate your test runs,
see quickstart: run Playwright tests at scale
Prerequisites
An Azure account with an active subscription. If you don't have an Azure
subscription, create a free account before you begin.
Your Azure account needs the Owner, Contributor, or one of the classic
administrator roles.
A Playwright project. If you don't have project, create one by using the Playwright
getting started documentation or use our Microsoft Playwright Testing sample
project .
Azure CLI. If you don't have Azure CLI, see Install Azure CLI.
Create a workspace
To get started with publishing test results on Playwright Testing service, first create a
Microsoft Playwright Testing workspace in the Playwright portal.
2. If you already have a workspace, select an existing workspace, and move to the
next step.
Tip
3. If you don't have a workspace yet, select + New workspace, and then provide the
following information:
ノ Expand table
Field Description
Azure Select the Azure subscription that you want to use for this Microsoft
subscription Playwright Testing workspace.
During the workspace creation, a new resource group and a Microsoft Playwright
Testing Azure resource are created in your Azure subscription.
When the workspace creation finishes, you're redirected to the setup guide.
npm
7 Note
If you already have this file, the prompt asks you to override it.
To use only reporting feature for the test run, disable cloud-hosted browsers by setting
useCloudHostedBrowsers as false.
TypeScript
Setting the value as false ensures that cloud-hosted browsers aren't used to run the
tests. The tests run on your local machine but the results and artifacts are published on
the service.
Tip
If you wish to accelerate your test run using cloud-hosted browser, you can set
useCloudHostedBrowsers as true. This will run your tests on the service managed
browsers.
1. In Add region endpoint in your setup, copy the region endpoint for your
workspace.
The endpoint URL matches the Azure region that you selected when creating the
workspace. Make sure this URL is available in PLAYWRIGHT_SERVICE_URL environment
variable.
We recommend that you use the dotenv module to manage your environment. With
dotenv , you define your environment variables in the .env file.
shell
PLAYWRIGHT_SERVICE_URL={MY-REGION-ENDPOINT}
Make sure to replace the {MY-REGION-ENDPOINT} text placeholder with the value you
copied earlier.
Set up authentication
To publish test results and artifacts to your Microsoft Playwright Testing workspace, you
need to authenticate the Playwright client where you're running the tests with the
service. The client could be your local dev machine or CI machine.
The service offers two authentication methods: Microsoft Entra ID and Access Tokens.
Microsoft Entra ID uses your Azure credentials, requiring a sign-in to your Azure account
for secure access. Alternatively, you can generate an access token from your Playwright
workspace and use it in your setup.
Microsoft Entra ID is the default and recommended authentication for the service. From
your local dev machine, you can use Azure CLI to sign-in
CLI
az login
7 Note
If you're a part of multiple Microsoft Entra tenants, make sure you sign in to the
tenant where your workspace belongs. You can get the tenant ID from Azure portal.
For more information, see Find your Microsoft Entra Tenant. Once you get the ID,
sign-in using the command az login --tenant <TenantID>
You can generate an access token from your Playwright Testing workspace and use it in
your setup. However, we strongly recommend Microsoft Entra ID for authentication due
to its enhanced security. Access tokens, while convenient, function like long-lived
passwords and are more susceptible to being compromised.
U Caution
TypeScript
use: {
trace: 'on-first-retry',
video:'retain-on-failure',
screenshot:'on'
}
Bash
7 Note
For the Reporting feature of Microsoft Playwright Testing, you get charged based
on the number test results published. If you're a first-time user or getting started
with a free trial, you might start with publishing single test result instead of your
full test suite to avoid exhausting your free trial limits.
After the test completes, you can view the test status in the terminal.
Output
U Caution
Depending on the size of your test suite, you might incur additional charges for the
test results beyond your allotted free test results.
1. After your test run completes, a link to the Playwright Portal is generated. Open
this link to view detailed test results and associated artifacts. The portal displays
essential information, including:
CI build details
Overall test run status
The commit ID linked to the test run
2. The Playwright portal provides all the necessary information for troubleshooting.
You can:
3. The Trace Viewer allows you to step through your test execution visually. You can:
Use the timeline to hover over individual steps, revealing the page state
before and after each action.
Inspect detailed logs, DOM snapshots, network activity, errors, and console
output for each step.
Tip
You can also use Microsoft Playwright Testing service to run tests in parallel using
cloud-hosted browsers. Both Reporting and cloud-hosted browsers are
independent features and are billed separately. You can use either of these or both.
For details, see How to use service features
7 Note
The test results and artifacts that you publish are retained on the service for 90
days. After that, they are automatically deleted.
Next step
You've successfully created a Microsoft Playwright Testing workspace in the Playwright
portal and run your Playwright tests on cloud browsers.
Advance to the next quickstart to set up continuous end-to-end testing by running your
Playwright tests in your CI/CD workflow.
Feedback
Was this page helpful? Yes No
Microsoft Playwright Testing Preview enables you to speed up your Playwright test
execution by increasing parallelism at cloud scale. Several factors affect the completion
time for your test suite. Determining the optimal configuration for reducing test suite
completion time is application-specific and requires experimentation. This article
explains the different levels to configure parallelism for your tests, the factors that
influence test duration, and how to determine your optimal configuration to minimize
test completion time.
In Playwright, you can run tests in parallel by using worker processes. By using Microsoft
Playwright Testing, you can further increase parallelism by using cloud-hosted browsers.
In general, adding more parallelism reduces the time to complete your test suite.
However, adding more worker processes doesn't always result in shorter test suite
completion times. For example, the client machine computing resources, network
latency, or test complexity might also affect test duration.
The following chart gives an example of running a test suite. By running the test suite
with Microsoft Playwright Testing instead of locally, you can significantly increase the
parallelism and reduce the test completion time. Notice that, when running with the
service, the completion time reaches a minimum limit, after which adding more workers
only has a minimal effect. The chart also shows how using more computing resources on
the client machine positively affects the test completion time for tests running with the
service.
Worker processes
In Playwright , all tests run in worker processes. These processes are OS processes,
running independently, in parallel, orchestrated by the Playwright Test runner. All
workers have identical environments and each process starts its own browser.
Generally, increasing the number of parallel workers can reduce the time it takes to
complete the full test suite. You can learn more about Playwright Test parallelism in
the Playwright documentation.
As previously shown in the chart, the test suite completion time doesn't continue to
decrease as you add more worker processes. There are other factors that influence the
test suite duration.
When you run tests locally, the number of worker processes is limited to the number of
CPU cores on your machine. Beyond a certain point, adding more workers leads to
resource contention, which slows down each worker and introduces test flakiness.
To override the number of workers using the --workers command line flag :
Bash
npx playwright test --workers=10
TypeScript
Because the worker processes still run on the client machine (developer workstation or
CI agent machine), the client machine might still become a bottleneck for scalable
execution as you add more workers. Learn how you can determine the optimal
configuration.
You can specify the number of workers on the command line with the --workers flag:
Bash
TypeScript
Client machine The worker processes still run on the client machine (developer
compute resources workstation or CI agent machine) and need to communicate with the
remote browsers. Increasing the number of parallel workers might
result in resource contention on the client machine, and slow down
tests.
Complexity of the test As the complexity of the test code increases, the time to complete the
code tests might also increase.
Latency between the The workers run on the client machine and communicate with the
client machine and the remote browsers. Depending on the Azure region where the browsers
remote browsers are hosted, the network latency might increase. Learn how you can
optimize regional latency in Microsoft Playwright Testing.
Target application's Running tests with Microsoft Playwright Testing enables you to run
load-handling capacity with higher parallelism, which results in a higher load on the target
application. Verify that the application can handle the load that is
generated by running your Playwright tests.
Learn more about the workflow for determining the optimal configuration for
minimizing the test suite duration.
The following approach can help you find the optimal configuration for running your
tests with Microsoft Playwright Testing:
Depending on the scenario, your requirements for test completion might be different.
When you're running your end-to-end tests with every code change, as part of a
continuous integration (CI) workflow, minimizing test completion time is essential. When
you schedule your end-to-end tests in a (nightly) batch run, you might have
requirements that are less demanding.
Get started with the Quickstart: run Playwright tests at scale with Microsoft Playwright
Testing.
Learn how you can optimize regional latency for your workspace.
7 Note
While the service is in preview, the number of parallel workers per workspace is
limited to 50. You can request an increase of this limit for your workspace .
Alternatively, if you have hardware limitations, you can shard your client tests.
Rerun your tests and experiment with the number of parallel workers.
Related content
Run your Playwright tests at scale with Microsoft Playwright Testing
What is Microsoft Playwright Testing
Optimize regional latency for a
workspace in Microsoft Playwright
Testing Preview
Article • 10/04/2023
Learn how to minimize the network latency between the client machine and the remote
browsers for a Microsoft Playwright Testing Preview workspace.
Microsoft Playwright Testing lets you run your Playwright tests on hosted browsers in
the Azure region that's nearest to your client machine. The service collects the test
results in the Azure region of the remote browsers, and then transfers the results to the
workspace region.
By default, when you create a new workspace, the service runs tests in an Azure region
closest to the client machine. When you disable this setting on the workspace, the
service uses remote browsers in the Azure region of the workspace.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
2. Select the workspace settings icon, and then go to the General page to view the
workspace settings.
Alternately, you can go directly to the Azure portal and select your workspace:
a. Sign in to the Azure portal .
b. Enter Playwright Testing in the search box, and then select Playwright Testing
in the Services category.
c. Select your Microsoft Playwright Testing workspace from the list.
By default, the service uses remote browsers in the Azure region that's closest to
the client machine to minimize latency.
Related content
Learn more about how to determine the optimal configuration for optimizing test
suite completion.
In this article, you create, view, and delete Microsoft Playwright Testing Preview
workspaces. You can access and manage a workspace in the Azure portal or in the
Playwright portal.
The following table lists the differences in functionality, based on how you access
Microsoft Playwright Testing:
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Prerequisites
An Azure account with an active subscription. Create an account for free .
Create a workspace
To get started with running your Playwright tests on cloud browsers, you first create a
Microsoft Playwright Testing workspace. You can create a workspace in either the Azure
portal or the Playwright portal.
Playwright portal
When you create a workspace in the Playwright portal, the service creates a new
resource group and a Microsoft Playwright Testing Azure resource in your Azure
subscription. The name of the new resource group is based on the workspace
name.
Tip
3. If you don't have a workspace yet, select + New workspace, and then provide
the following information:
Field Description
Azure Select the Azure subscription that you want to use for this
subscription Microsoft Playwright Testing workspace.
Playwright portal
2. Select your current workspace in the top of the screen, and then select
Manage all workspaces.
3. On the Workspaces page, you can now see all the workspaces that you have
access to.
The page shows a card for each of the workspaces in the currently selected
Azure subscription. You can switch to another subscription by selecting a
subscription from the list.
Tip
The workspace activity log lists for each test run the following details:
3. On the workspace home page, you can view the workspace activity log.
Delete a workspace
To delete a Playwright workspace:
Playwright portal
2. Select your current workspace in the top of the screen, and then select
Manage all workspaces.
3. On the Workspaces page, select the ellipsis (...) next to your workspace, and
then select Delete workspace.
4. On the Delete Workspace page, select Delete to confirm the deletion of the
workspace.
2 Warning
Related content
Optimize regional latency for a workspace
In this article, you learn how to manage workspace access tokens in Microsoft
Playwright Testing Preview. You use access tokens to authenticate and authorize access
to your workspace.
Access tokens are associated with a user account and workspace. When you use an
access token for running Playwright tests, the service checks your Azure role-based
access control (Azure RBAC) role to verify if you're granted access to run tests on the
service. Learn more about workspace access in Microsoft Playwright Testing.
You can create multiple access tokens per workspace, for example to distinguish
between running tests interactively or as part of your continuous integration (CI)
workflow. When you create an access token, the token has a limited lifespan.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Prerequisites
An Azure account with an active subscription. Create an account for free .
A Microsoft Playwright Testing workspace. To create a workspace, see Quickstart:
Run Playwright tests at scale.
To create or delete access tokens, your Azure account needs to have the
Contributor or Owner role at the workspace level. Learn more about managing
access to a workspace.
Revoke and recreate your tokens if you believe they may have been compromised.
You can only view the list of access tokens for the workspaces you have access to.
3. Select the settings icon on the home page to go to the workspace settings.
4. Select the Access tokens page to view the list of access tokens.
The Access tokens page displays the list of access tokens for the workspace.
When you use an access token, the service checks the Azure RBAC role of the user that
is associated with the access token to verify that the required permissions are granted.
For example, if you have the Reader role, you can't run Playwright tests but you can view
the test results. When there are role assignment changes, the service checks the
permissions at the time you perform the action.
3. Select the settings icon on the home page to go to the workspace settings.
5. Enter the access token details, and then select Generate token.
You can save the access token in a CI/CD secrets store or use it in an environment
variable for running tests interactively.
) Important
You can only access the token value immediately after you've created it. You
can't access the token value anymore at a later time.
7 Note
The number of access tokens per user and per workspace is limited. For more
information, see the Microsoft Playwright Testing service limits.
3. Select the settings icon on the home page to go to the workspace settings.
4. On the Access tokens page, select Delete next to the access token that you want
to delete.
U Caution
You can't undo the delete operation of an access token. Any existing scripts for
running tests with this token will fail after deleting the access token.
Related content
Learn more about managing access to a workspace.
Learn more about managing authentication to the workspace
Feedback
Was this page helpful? Yes No
In this article, you learn how to manage access to a workspace in Microsoft Playwright
Testing Preview. The service uses Azure role-based access control (Azure RBAC) to
authorize access rights to your workspace. Role assignments are the way you control
access to resources using Azure RBAC.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Prerequisites
To assign roles in Azure, your account needs the User Access Administrator, Owner,
or one of the classic administrator roles.
Default roles
Microsoft Playwright Testing workspaces uses three Azure built-in roles. To grant users
access to a workspace, you assign them one of the following Azure built-in roles:
Contributor - Full access to manage the workspace in the Azure portal but can't assign roles in
Azure RBAC.
- Full access to the workspace in the Playwright portal.
- Create and delete their access tokens.
- Run Playwright tests on the service.
Owner - Full access to manage the workspace in the Azure portal, including assigning roles
in Azure RBAC.
- Full access to the workspace in the Playwright portal.
- Create and delete their access tokens.
- Run Playwright tests on the service.
) Important
Before you assign an Azure RBAC role, determine the scope of access that is
needed. Best practices dictate that it's always best to grant only the narrowest
possible scope. Azure RBAC roles defined at a broader scope are inherited by the
resources beneath them. For more information about scope for Azure RBAC role
assignments, see Understand scope for Azure RBAC.
2. Select the workspace settings icon, and then go to the Users page.
3. Select Manage users for your workspace in the Azure portal to go to your
workspace in the Azure portal.
Alternately, you can go directly to the Azure portal and select your workspace:
a. Sign in to the Azure portal .
b. Enter Playwright Testing in the search box, and then select Playwright Testing
in the Services category.
c. Select your Microsoft Playwright Testing workspace from the list.
d. On the left pane, select Access Control (IAM).
4. On the Access Control (IAM) page, select Add > Add role assignment.
If you don't have permissions to assign roles, the Add role assignment option is
disabled.
6. Select one of the Microsoft Playwright Testing default roles, and then select Next.
7. On the Members tab, make sure User, group, or service principal is selected.
8. Select Select members, find and select the users, groups, or service principals.
For more information about how to assign roles, see Assign Azure roles using the
Azure portal.
2. On the left pane, select Access Control (IAM), and then select Role assignments.
3. In the list of role assignments, add a checkmark next to the user and role you want
to remove, and then select Remove.
4. Select Yes in the confirmation window to remove the role assignment.
For more information about how to remove role assignments, see Remove Azure
role assignments.
Avoid the need for granting team or project leaders the Owner role on the
workspace. You can grant them access only to the security group to let them
manage access to the workspace.
You can organize, manage and revoke users' permissions on a workspace and
other resources as a group, without having to manage permissions on a user-by-
user basis.
Using Microsoft Entra groups helps you to avoid reaching the subscription limit on
role assignments.
2. Add a group owner. This user has permissions to add or remove group members.
The group owner isn't required to be group member, or have direct RBAC role on
the workspace.
3. Assign the group an RBAC role on the workspace, such as Reader or Contributor.
4. Add group members. The added members can now access to the workspace.
4. Follow these steps to add a role assignment for the custom role to the user
account.
Troubleshooting
Here are a few things to be aware of while you use Azure role-based access control
(Azure RBAC):
When you create a resource in Azure, such as a workspace, you are not
automatically the owner of the resource. Your role is inherited from the highest
scope role that you're authorized against in that subscription. As an example, if
you're a Contributor for the subscription, you have the permissions to create a
Microsoft Playwright Testing workspace. However, you would be assigned the
Contributor role against that workspace, and not the Owner role.
When there are two role assignments to the same Microsoft Entra user with
conflicting sections of Actions/NotActions, your operations listed in NotActions
from one role might not take effect if they're also listed as Actions in another role.
To learn more about how Azure parses role assignments, read How Azure RBAC
determines if a user has access to a resource.
It can sometimes take up to 1 hour for your new role assignments to take effect
over cached permissions.
Related content
Get started with running Playwright tests at scale
Learn how to use Microsoft Playwright Testing Preview to run end-to-end tests for
locally deployed applications. Microsoft Playwright Testing uses cloud-hosted, remote
browsers for running Playwright tests at scale. You can use the service to run tests for
apps on localhost, or that you host on your infrastructure.
Playwright enables you to expose networks that are available on the client machine to
remote browsers. When you expose a network, you can connect to local resources from
your Playwright test code without having to configure additional firewall settings.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
You can specify one or multiple networks by using a list of rules. For example, to expose
test/staging deployments and localhost : *.test.internal-domain,*.staging.internal-
domain,<loopback> .
TypeScript
import { getServiceConfig, ServiceOS } from "@azure/microsoft-playwright-
testing";
import { defineConfig } from "@playwright/test";
import { AzureCliCredential } from "@azure/identity";
import config from "./playwright.config";
You can now reference localhost in the Playwright test code, and run the tests on
cloud-hosted browsers with Microsoft Playwright Testing:
Bash
Related content
Run Playwright tests at scale with Microsoft Playwright Testing
Learn more about writing Playwright tests in the Playwright documentation
Feedback
Was this page helpful? Yes No
In this article, you learn how to properly configure Playwright's visual comparison tests
when using Microsoft Playwright Testing Preview. Unexpected test failures may occur
because Playwright's snapshots differ between local and remote browsers.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Background
The Playwright Test runner uses the host OS as a part of the expected screenshot path. If
you're running tests using remote browsers on a different OS than your host machine,
the visual comparison tests fail. Our recommendation is to only run visual comparisons
when using the service. If you're taking screenshots on the service, there's no need to
compare them to your local setup since they don't match.
Configure ignoreSnapshots
You can use the ignoreSnapshots option to only run visual comparisons when using
Microsoft Playwright Testing.
When you're using the service, its configuration overrides playwright.config.ts , and
runs visual comparisons.
JavaScript
// This path is exactly like the default path, but replaces OS with
hardcoded value that is used on the service (linux).
config.snapshotPathTemplate = '{snapshotDir}/{testFileDir}/{testFileName}-
snapshots/{arg}{-projectName}-linux{ext}'
typeScript
Related content
Learn more about Playwright Visual Comparisons .
Feedback
Was this page helpful? Yes No
When you have critical applications and business processes relying on Azure resources,
you want to monitor those resources for their availability, performance, and operation.
This article describes the monitoring data generated by Microsoft Playwright Testing
Preview.
Microsoft Playwright Testing creates monitoring data using Azure Monitor, which is a full
stack monitoring service in Azure. Azure Monitor provides a complete set of features to
monitor your Azure resources. It can also monitor resources in other clouds and on-
premises. Learn more about monitoring Azure resources with Azure Monitor.
Tip
To understand costs associated with Azure Monitor, see Usage and estimated
costs . To understand the time it takes for your data to appear in Azure Monitor,
see Log data ingestion time.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Monitoring data
Microsoft Playwright Testing collects the same kinds of monitoring data as other Azure
resources that are described in Monitoring data from Azure resources.
See Monitor Microsoft Playwright Testing data reference for detailed information on
logs metrics created by Microsoft Playwright Testing.
See Create diagnostic setting to collect platform logs and metrics in Azure for the
detailed process for creating a diagnostic setting using the Azure portal, CLI, or
PowerShell. When you create a diagnostic setting, you specify which categories of logs
to collect.
The log categories for Microsoft Playwright Testing are listed in Monitor Microsoft
Playwright Testing data reference.
Analyzing logs
Data in Azure Monitor Logs is stored in tables where each table has its own set of
unique properties. All resource logs in Azure Monitor have the same fields followed by
service-specific fields. The common schema is outlined in Azure Monitor resource log
schema.
You can find the schema for Microsoft Playwright Testing resource logs in the Monitor
Microsoft Playwright Testing data reference.
The Activity log is a type of Azure platform log that provides insight into subscription-
level events. You can view it independently or route it to Azure Monitor Logs, where you
can do much more complex queries using Log Analytics.
For a list of resource logs types collected for Microsoft Playwright Testing, see Monitor
Microsoft Playwright Testing data reference.
Related content
See Monitor Microsoft Playwright Testing data reference for a reference of the
metrics, logs, and other important values created by Microsoft Playwright Testing.
See Monitoring Azure resources with Azure Monitor for details on monitoring
Azure resources.
Use Microsoft Playwright Testing
Reporting preview with Playwright
sharding
Article • 12/30/2024
In this article, you learn how to use the Microsoft Playwright Testing service's reporting
feature with test runs that use Playwright's sharding features .
Playwright's sharding enables you to split your test suite to run across multiple
machines simultaneously. This feature helps running tests in parallel.
You can use Playwright Testing's reporting feature to get a consolidated report of a test
run with sharding. Ensure the runId of the test run is same across all shards.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Prerequisites
An Azure account with an active subscription. If you don't have an Azure
subscription, create a free account before you begin.
TypeScript
You can use PLAYWRIGHT_SERVICE_RUN_ID variable in your setup to ensure the runId
remains same across all shards.
Set up variables
The runId setting is used as an identifier by Playwright Testing service to distinguish
between test runs. The results from multiple runs with same runId are reported to the
same run on the Playwright portal.
By default, a test run that uses reporting feature automatically generates a unique runId
unless you explicitly set the value yourself. If the value of the variable remains same
across runs, the results are reported together in the same run on the Playwright portal.
Tip
While using sharding, make sure the same runId is set across all the shards for the
results to be reported together. Use the variable PLAYWRIGHT_SERVICE_RUN_ID and set the
value same across all shards.
Here's an example of how you can set it in your pipeline via GitHub Actions.
yml
Feedback
Was this page helpful? Yes No
In this article, you learn how to manage authentication and authorization for Microsoft
Playwright Testing preview. Authentication is required to run Playwright tests on cloud-
hosted browsers and to publish test results and artifacts to the service.
By default, Microsoft Entra ID is used for authentication. This method is more secure and
is the recommended authentication method. You can't disable authentication using
Microsoft Entra ID. However, you can also use access tokens to authenticate and
authorize.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Background
Microsoft Playwright Testing Preview is built on the Playwright open-source framework.
It runs Playwright tests on cloud-hosted browsers and publishes reports and artifacts
back to the service.
To use the service, the client must authenticate with the service to access the browsers.
Similarly, publishing results and artifacts requires authenticated API interactions. The
service offers two authentication methods: Microsoft Entra ID and access tokens.
Microsoft Entra ID uses your Azure credentials, requiring a sign-in to your Azure account
for secure access. Alternatively, you can generate an access token from your Playwright
workspace and use it in your setup. However, we strongly recommend Microsoft Entra
ID for authentication due to its enhanced security. Access tokens, while convenient,
function like long-lived passwords and are more susceptible to being compromised.
U Caution
Your workspace access tokens are similar to a password for your Microsoft
Playwright Testing workspace. Always be careful to protect your access tokens.
Avoid distributing access tokens to other users, hard-coding them, or saving them
anywhere in plain text that is accessible to others.
Revoke and recreate your tokens if you believe they are compromised.
1. Sign in to the Playwright portal with your Azure account and select your
workspace.
2. Select the settings icon on the home page to go to the workspace settings.
3. Select the Authentication page and turn on Enable authentication using Access
tokens
U Caution
Authentication using access tokens is less secure. Learn how to manage access
tokens
Follow the steps to create an access token. Copy the value of the access token
generated.
We recommend that you use the dotenv module to manage your environment.
With dotenv , you define your environment variables in the .env file.
shell
PLAYWRIGHT_SERVICE_ACCESS_TOKEN={MY-ACCESS-TOKEN}
Make sure to replace the {MY-ACCESS-TOKEN} text placeholder with the value you
copied earlier.
TypeScript
npx playwright test --config=playwright.service.config.ts --workers=20
Related content
Learn more about managing access tokens.
Feedback
Was this page helpful? Yes No
In this article, you learn how to use the features provided by Microsoft Playwright
Testing preview.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Prerequisites
An Azure account with an active subscription. Create an account for free .
A Microsoft Playwright Testing workspace. To create a workspace, see Quickstart:
Run Playwright tests at scale.
To manage features, your Azure account needs to have the Contributor or Owner
role at the workspace level. Learn more about managing access to a workspace.
Background
Microsoft Playwright Testing preview allows you to:
These features have their own pricing plans and are billed separately. You can choose to
use either feature or both. These features can be enabled or disabled for the workspace
or for any specific run. To know more about pricing, see Microsoft Playwright Testing
preview pricing
Currently, you can choose to enable or disable only reporting feature of the
service. By default, reporting is enabled for the workspace.
) Important
You can only use a feature in a test run if it is enabled for the workspace.
1. In your Playwright setup, go to playwright.service.config.ts file and use these
settings for feature management.
TypeScript
useCloudHostedBrowsers :
Description: This setting allows you to choose whether to use cloud-hosted
browsers or the browsers on your client machine to run your Playwright tests. If
you disable this option, your tests run on the browsers of your client machine
instead of cloud-hosted browsers, and you do not incur any charges. You can
still configure reporting options.
Default Value: true
Example:
TypeScript
useCloudHostedBrowsers: true
reporter
TypeScript
reporter: [
["list"],
["@azure/microsoft-playwright-testing/reporter"]],
Related content
Learn more about Microsoft Playwright Testing preview pricing .
Feedback
Was this page helpful? Yes No
This article shows you how to use the options available in the
playwright.service.config.ts file that was generated for you. If you don't have this file
in your code, follow Quickstart: Run end-to-end tests at scale with Microsoft Playwright
Testing Preview
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Prerequisites
Follow the Quickstart guide and set up a project to run with Microsoft Playwright
Testing service. See, Quickstart: Run end-to-end tests at scale with Microsoft
Playwright Testing Preview
Here's version of the playwright.service.config.ts file with all the available options:
TypeScript
Description: This setting allows you to choose the authentication method you
want to use for your test run.
Available Options:
ACCESS_TOKEN to use access tokens. You need to enable authentication using
access tokens if you want to use this option, see manage authentication.
ENTRA_ID to use Microsoft Entra ID for authentication. It's the default mode.
TypeScript
serviceAuthType:'ENTRA_ID'
os :
Description: This setting allows you to choose the operating system where the
browsers running Playwright tests are hosted.
Available Options:
ServiceOS.WINDOWS for Windows OS.
ServiceOS.LINUX for Linux OS.
TypeScript
os: ServiceOS.WINDOWS
runId :
Description: This setting allows you to set a unique ID for every test run to
distinguish them in the service portal. Using the same runId for multiple test
runs results in error. For sharding, keep this same across all shards.
Example:
TypeScript
credential :
Description: This setting allows you to select the authentication method you
want to use with Microsoft Entra ID.
Example:
TypeScript
useCloudHostedBrowsers
TypeScript
useCloudHostedBrowsers: true
exposeNetwork
Description: This setting allows you to connect to local resources from your
Playwright test code without having to configure another firewall settings. To
learn more, see how to test local applications
Example:
TypeScript
exposeNetwork: '<loopback>'
timeout
Description: This setting allows you to set timeout for your tests connecting to
the cloud-hosted browsers.
Example:
TypeScript
timeout: 30000,
reporter
TypeScript
reporter: [
["list"],
["@azure/microsoft-playwright-testing/reporter"],
enableGitHubSummary :
TypeScript
reporter: [
["list"],
[
"@azure/microsoft-playwright-testing/reporter",
{
enableGitHubSummary: true,
},
],
]
Feedback
Was this page helpful? Yes No
In this tutorial, you learn how to integrate your Playwright test suite with Microsoft
Playwright Testing, run tests faster using cloud-hosted browsers, and troubleshoot
efficiently using the service's reporting features. You simulate a Playwright test suite,
connect it to the service for faster execution, and use reporting tools for streamlined
troubleshooting.
Prerequisites
An Azure account with an active subscription. If you don't have an Azure
subscription, create a free account before you begin.
The Azure CLI installed on your local computer.
Azure CLI version 2.2.0 or later. Run az --version to check the installed version on
your computer. If you need to install or upgrade the Azure CLI, see How to install
the Azure CLI.
Visual Studio Code. If you don't have it, download and install it .
Git. If you don't have it, download and install it .
Prerequisites check
Before you start, validate your environment:
Sign in to the Azure portal and check that your subscription is active.
Check your version of the Azure CLI in a terminal or command window by running
az --version . For the latest version, see the latest release notes.
If you don't have the latest version, update your installation by following the
installation guide for your operating system or platform.
Set up Playwright test suite
In this step, you are creating a Playwright test suite which is integrated with the service.
PowerShell
2. Install dependencies.
PowerShell
npm install
Run this command to execute tests locally, outside of the service, to identify any
problems before integrating with the service. This project is used in the next steps to
integrate with the service.
PowerShell
Follow these steps to set up the service and integrate the test suite.
Tip
3. If you don't have a workspace yet, select + New workspace, and then provide the
following information:
ノ Expand table
Field Description
Azure Select the Azure subscription that you want to use for this Microsoft
subscription Playwright Testing workspace.
During the workspace creation, a new resource group and a Microsoft Playwright
Testing Azure resource are created in your Azure subscription.
When the workspace creation finishes, you're redirected to the setup guide.
npm
1. In Add region endpoint in your setup, copy the region endpoint for your
workspace.
The endpoint URL matches the Azure region that you selected when creating the
workspace. Ensure this URL is available in PLAYWRIGHT_SERVICE_URL environment
variable.
We recommend that you use the dotenv module to manage your environment. With
dotenv , you define your environment variables in the .env file.
1. Add the dotenv module to your project:
shell
PLAYWRIGHT_SERVICE_URL={MY-REGION-ENDPOINT}
Make sure to replace the {MY-REGION-ENDPOINT} text placeholder with the value you
copied earlier.
Set up authentication
To run your Playwright tests in your Microsoft Playwright Testing workspace, you need
to authenticate the Playwright client where you're running the tests with the service.
Authenticate with the dev workstation where you are running the Playwright tests.
Microsoft Entra ID is the default and recommended authentication for the service. Use
Azure CLI to sign-in
CLI
az login
7 Note
If you're a part of multiple Microsoft Entra tenants, make sure you sign in to the
tenant where your workspace belongs. You can get the tenant ID from Azure portal.
See Find your Microsoft Entra Tenant. Once you get the ID, sign-in using the
command az login --tenant <TenantID>
use: {
trace: 'on-first-retry',
video:'retain-on-failure',
screenshot:'on'
}
Follow these steps to run Playwright tests with Microsoft Playwright Testing:
2. Enter the following command to run your Playwright test suite on remote browsers
and publish test results to your workspace.
Bash
After the test completes, you can view the test status in the terminal.
Output
1. After your test run completes, a link to the Playwright Portal is generated. Open
this link to view detailed test results and associated artifacts. The portal displays
essential information, including:
CI build details
Overall test run status
The commit ID linked to the test run
2. The Playwright portal provides all the necessary information for troubleshooting.
You can:
3. The Trace Viewer allows you to step through your test execution visually. You can:
Use the timeline to hover over individual steps, revealing the page state
before and after each action.
Inspect detailed logs, DOM snapshots, network activity, errors, and console
output for each step.
Tip
You can use Microsoft Playwright Testing service features independently. You can
publish test results to the portal without using the cloud-hosted browsers feature
and you can also use only cloud-hosted browsers to expedite your test suite
without publishing test results.
7 Note
The test results and artifacts that you publish are retained on the service for 90
days. After that, they are automatically deleted.
Next steps
Set up continuous end-to-end testing in CI/CD
Explore service configuration options
Determine the optimal test suite configuration
Feedback
Was this page helpful? Yes No
Symptoms
When using Microsoft Playwright Testing, you fail to sign into the Playwright portal. You
receive the following error message:
Cause
This issue occurs if the service principal for Microsoft Playwright Testing is disabled for
the tenant.
Resolution
To resolve this issue, you need to enable the service principal for Microsoft Playwright
Testing for the tenant.
) Important
Follow these steps to enable the Microsoft Playwright Testing service principal:
2. Install the Microsoft Azure Active Directory module for Windows PowerShell by
running the following cmdlet:
PowerShell
Install-Module MSOnline
3. Connect to Microsoft Entra ID for your Microsoft 365 subscription by running the
following cmdlet:
PowerShell
Connect-MsolService
4. Check the current status of the service principal for Microsoft Playwright Testing by
running the following cmdlet:
PowerShell
5. Enable the service principal for Microsoft Playwright Testing by running the
following cmdlet:
PowerShell
This article addresses issues that might arise when you run Playwright tests at scale with
Microsoft Playwright Testing Preview.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Search for any instances of pause() statements in your code and comment them out.
Sending the Playwright trace files from the service to the client machine can create
congestion, which can cause tests to fail due to a timeout.You can disable tracing
in the Playwright configuration file .
You can mitigate the issue by specifying the time zone in the Playwright configuration
file .
To resolve this issue, you should use the saveAs() function to save a local copy of the
file on your client machine. Learn more about downloads in the Playwright
documentation .
The following code snippet gives an example of how to use saveAs() instead of path()
for reading the contents of a downloaded file:
TypeScript
Related content
Manage workspace access
Optimize regional latency a workspace
Service limits in Microsoft Playwright
Testing Preview
Article • 12/24/2024
Azure uses limits and quotas to prevent budget overruns due to fraud, and to honor
Azure capacity constraints. Consider these limits as you scale for production workloads.
In this article, you learn about:
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
ノ Expand table
Resource Limit
Other limitations
Moving a workspace to another resource group is not yet supported.
The Playwright Testing service portal is only available in English. Localization in
other languages is currently in progress.
Outbound IP addresses
This section lists the outbound IP address ranges that Microsoft Playwright Testing
requires to communicate through your firewall.
ノ Expand table
East US 52.190.15.208/28
Related content
Get started and run Playwright tests at scale
Feedback
Was this page helpful? Yes No
Learn about the data and resources collected by Azure Monitor from your workspace in
Microsoft Playwright Testing Preview. See Monitor Microsoft Playwright Testing for
details on collecting and analyzing monitoring data.
) Important
Microsoft Playwright Testing is currently in preview. For legal terms that apply to
Azure features that are in beta, in preview, or otherwise not yet released into
general availability, see the Supplemental Terms of Use for Microsoft Azure
Previews .
Resource logs
This section lists the types of resource logs you can collect for Microsoft Playwright
Testing.
Operational logs
Operational log entries include elements listed in the following table:
Name Description
Related content
See Monitor Microsoft Playwright Testing for a description of monitoring Microsoft
Playwright Testing.
See Monitor Azure resources with Azure Monitor for details on monitoring Azure
resources.
The Trace Viewer in Playwright Testing facilitates in-depth test validation and analysis by allowing users to visually step through test execution. It provides a timeline to hover over individual test steps, revealing the page state before and after each action . Users can inspect detailed logs, DOM snapshots, network activity, errors, and console output for each step, providing a comprehensive understanding of the test behavior past simple pass/fail results . This capability supports identifying the causes of test failures and verifying the nuances of test executions efficiently .
Microsoft Playwright Testing manages user roles and permissions through Azure role-based access control (RBAC). An Azure account with an active subscription is required, and users need the Owner or Contributor roles to manage workspaces or access tokens. This system ensures that only authorized users can create, delete, or manage workspaces within the Playwright portal .
Microsoft Playwright Testing's reporting features enhance troubleshooting by providing access to detailed test results and artifacts in the Playwright portal. This portal displays CI build details, test run status, and the commit ID, offering essential information for troubleshooting . Users can switch between retries, view detailed error logs, inspect test steps, and access attached artifacts like screenshots or videos . The Trace Viewer allows users to visually step through test executions, inspect logs, DOM snapshots, network activity, errors, and console output for each step . This comprehensive access to test artifacts and traceability simplifies identifying and resolving issues in test executions .
To optimize Playwright test suites using cloud-hosted browsers, it is important to configure parallelism correctly. Increasing the number of worker processes can reduce test completion times, but it requires balancing the client machine's resources and network latency. Additionally, utilizing detailed test logs and artifacts to identify bottlenecks can streamline the process. It may also be beneficial to run initial tests on a smaller scale before scaling up to avoid consuming excess resources or exceeding budgets .
Access tokens in Microsoft Playwright Testing are used as an alternative to Microsoft Entra ID for authenticating and authorizing access to run tests on cloud-hosted browsers and to publish test results to the service . Despite their convenience, access tokens function like long-lived passwords and have a higher risk of being compromised, which is why using Microsoft Entra ID is recommended due to its enhanced security . To handle access tokens securely, they should not be distributed to users, hard-coded in scripts, or stored in plain text . Instead, store them in a CI/CD secrets store or configure them as environment variables to ensure secure handling. Additionally, revoke and recreate access tokens if they are believed to be compromised .
First-time users of Microsoft Playwright Testing may face multiple cost implications. These include data transfer costs due to potential network latency if the client machine or web application is located outside the Azure regions where the hosted browsers are available, which can also affect test execution speed . Additionally, using features like cloud-hosted browsers and reporting independently or together is billed separately, so users may incur charges for these if not within the free-trial limits . To manage these costs, first-time users should experiment to find the optimal parallel workers and service configurations that strike a balance between cost and performance. This involves evaluating the CI/CD workflows, test completion goals, and the application's load-handling capacity . Disabling non-essential features like cloud-hosted browsers can also reduce costs if tests can be efficiently run on client machines without affecting outcome quality .
Enhancing performance of Playwright test suites in continuous integration pipelines can be achieved by utilizing Playwright Testing features. Users can integrate their existing Playwright code with Microsoft Playwright Testing to leverage cloud-hosted remote browsers, which improves test consistency and performance across different environments without altering code . Running tests in parallel is crucial for performance enhancement. Users can increase the number of parallel workers, which can drastically reduce test completion times; Microsoft Playwright Testing supports scaling tests with remote browsers, supporting up to 50 parallel workers in preview mode . Additionally, configuring regional settings to match client machines and remote browsers can help minimize latency and improve speed . Other optimizations include exposing local network resources for seamless access from remote browsers using the "exposeNetwork" option . Moreover, the reporting feature integrates with CI pipelines to provide rich, consolidated reports, making it easier to troubleshoot and improve test suite efficiency .
The implementation of Microsoft Entra ID enhances authentication practices within Playwright Testing environments by providing a more secure method for authentication compared to access tokens. Microsoft Entra ID uses Azure credentials and requires users to sign in to their Azure account, offering strong protection against unauthorized access and reducing the risk of credential compromise. This method is recommended due to its higher security level and is the default for Microsoft Playwright Testing. Access tokens, in contrast, act like long-lived passwords and are more vulnerable to being compromised. Therefore, Microsoft Entra ID is preferred for its enhanced security features .
To create a new Playwright Testing workspace, sign in to the Playwright portal with your Azure account. If you already have a workspace, select it, or create a new one by clicking + New workspace. Provide a unique name, select an Azure subscription, and choose a region where the data will be stored. Click Create workspace; this action creates a new resource group and a Playwright Testing Azure resource in your subscription . To manage multiple workspaces effectively, sign in to the Playwright portal and select Manage all workspaces to view the list of accessible workspaces. You can switch between workspaces by selecting the desired one from the list. For each workspace, you can view details and access the activity log to analyze test runs. This allows for efficient oversight and management of test data across different environments .
Microsoft Playwright Testing offers a flexible pricing model where users pay based on the features they choose to enable, such as reporting and cloud-hosted browsers. The service is currently in preview and incorporates both free and potentially billable elements. Reporting can be enabled independently of cloud-hosted browsers, meaning you can get billed for reporting even if you run tests locally . You can choose to use local devices to avoid charges from cloud-hosted services . This pricing flexibility allows users to avoid unnecessary costs by disabling cloud-hosted browsers or service features unused in their testing setup .