Azure Playwright Testing Service (Preview) allows you to run Playwright tests on cloud‑hosted browsers without managing infrastructure. This post walks through setting up a workspace, configuring your project, and running UI and API tests using Visual Studio or VS Code.
Overview
End‑to‑end testing at scale is a common challenge when teams need reliable, cross‑browser validation without managing infrastructure. Azure Playwright Testing Service (Preview) simplifies this by allowing you to run Playwright tests on cloud-hosted browsers directly from your local setup.
In this post, I’ll walk through how to:
- Set up Azure Playwright Testing Service
- Configure your Playwright project
- Run UI and API tests on remote browsers
- View execution logs, HTML reports, and traces
This guide uses Playwright with TypeScript in Visual Studio / VS Code and is based on hands‑on setup steps.
Prerequisites
Before you begin, ensure you have:
- An active Azure subscription
- Node.js installed
- A Playwright project using TypeScript
- Visual Studio or Visual Studio Code
Step 1: Create a Playwright Workspace in Azure Portal
- Go to Azure Portal → Microsoft Playwright Testing (Preview)
- Select your subscription and region
- Create a new workspace
Once created, the workspace will serve as the execution environment for your cloud browser tests.
Step 2: Create a Playwright Project Locally
Create a Playwright project in Visual Studio or VS Code and add your test cases under the tests folder.
Example structure:
tests/
└── example.spec.ts
Your Playwright tests will be executed from this project using Azure-hosted browsers.
Step 3: Add Playwright Service Configuration
- Open your Azure Playwright workspace
- On the Home page, download the Playwright service configuration file
- Link provided in portal: https://aka.ms/mpt/service-config
- Add the file (playwright.service.config.ts) to your project
- Place it in the same directory as playwright.config.ts
This configuration enables communication between your local tests and the cloud service.
Step 4: Generate Access Token and Service URL
Within the Playwright Testing portal:
- Generate a new access token
- Copy:
- Access Token
- Region-specific Service URL
Step 5: Configure Environment Variables
Create a .env file in the same folder as your config files and add:
PLAYWRIGHT_SERVICE_ACCESS_TOKEN={YOUR_ACCESS_TOKEN} PLAYWRIGHT_SERVICE_URL={YOUR_REGION_ENDPOINT}
These values authenticate your test runs with Azure Playwright Testing Service.
Step 6: Install Playwright VS Code Extension (Optional)
For an improved developer experience, install the Playwright Test extension:
- https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright
Step 7: Run Tests on Remote Browsers
Open a terminal and run:
To execute a specific test file:
npx playwright test example.spec.ts --config=playwright.service.config.ts
To execute the entire test suite in parallel:
npx playwright test --config=playwright.service.config.ts --workers=20
To open the latest HTML report:
npx playwright show-report
Step 8: Monitor Test Execution in Azure Portal
Return to the Playwright Testing portal and refresh the workspace to view:
- Test cases executed
- Test suite runtime
- Execution time across browsers
- Activity logs for each run
An HTML report is automatically generated, showing:
- Passed and failed test cases
- Detailed error logs
- Step‑by‑step execution data
Both passed and failed logs are available in the report for analysis.
Viewing Traces and Debugging Failures
To analyze detailed execution flows:
- Install Playwright Trace Viewer
- Open the stdout or trace file from the test run
This helps inspect:
- UI actions
- Timing
- DOM state at each step
Running API Tests with Playwright
You can also execute API test cases alongside UI tests by defining request configurations and assertions within Playwright.
This enables combining UI and API validations into a single testing pipeline.
Playwright Testing with Visual Studio and TypeScript
For Visual Studio users:
- Use the same .env and playwright.service.config.ts
- Install dotenv:
npm install --save-dev dotenv
Run the test suite:
npx playwright test --config=playwright.service.config.ts --workers=20
View execution details in the Playwright portal: https://aka.ms/mpt/portal
What’s Next?
- Explore parallel test execution to reduce runtime
- Add trace analysis as part of CI debugging
- Extend the setup into CI/CD workflows
- Combine Playwright UI and API tests for end‑to‑end validation
Have you tried Azure Playwright Testing Service yet?
Share your experience or questions in the comments!😁