Run C# Playwright-Android tests on BrowserStack Automate
Learn how to run your C# Playwright Android tests on BrowserStack Automate using the BrowserStack.Playwright package for .NET
Use the BrowserStack.Playwright NuGet package to run Playwright Android tests written in C# on real devices via BrowserStack Automate. This guide shows you how to install the package, configure capabilities, connect to an Android device, run a sample script, and mark the session status.
Prerequisites
- BrowserStack Username and Access key. You can find this in your account profile. If you have not created an account yet, you can sign up for a Free Trial.
- You have .NET 6.0 or later installed (run:
dotnet --version). - You have removed any existing
Microsoft.Playwrightpackage to avoid conflicts.
Perform the steps given below to run a Playwright-Android test:
Install the BrowserStack Playwright package
Run the given command to add the BrowserStack.Playwright dependency to your project.
Understand required capabilities
You must pass a capabilities JSON when establishing the WebSocket connection. Below are some key capability fields:
-
browserstack.username/browserstack.accessKey: Your credentials. -
browser:chrome(Android currently supports Chrome). -
device: Device name (Example: Samsung Galaxy S25 Ultra). -
os_version: Android OS version. -
name: Your test name (shown in Automate dashboard). -
client.playwrightVersion: Local Playwright version. -
browserstack.playwrightVersion: Remote Playwright version on BrowserStack (keep aligned for API compatibility). -
browserstack.console:info,errors,warningsfor console log verbosity.
Keep version pairs updated when upgrading locally.
Sample C# Android automation script
The following is a sample test script
This script:
- Connects to a BrowserStack Android device.
- Launches a browser context.
- Navigates to Google.
- Marks the session as passed.
Run the test
Run the given command to execute the test on BrowserStack:
The test connects to a real Android device, opens Chrome, loads Google, and ends the session.
View results in Automate dashboard
After the run:
- Navigate to the BrowserStack Automate Dashboard.
- Open the session named sample_android_playwright_test.
- Verify device, logs, and marked status (Passed).
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
- RESOURCES
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!