Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

Run C# Playwright-iOS tests on BrowserStack Automate

Learn how to run your C# Playwright iOS tests on BrowserStack Automate using the BrowserStack.Playwright package for .NET

Use the BrowserStack.Playwright NuGet package to run Playwright iOS tests written in C# on real devices via BrowserStack Automate. This guide shows you how to install the package, configure capabilities, connect to an iOS 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.
  • You have removed any and all existing Microsoft.Playwright packages to avoid conflicts.

Perform the steps given below to run a Playwright-iOS test:

Set your credentials securely

Execute the given command to set environment variables:

terminal
Copy icon Copy

Remove all Microsoft.Playwright packages

Before you proceed, remove all Microsoft.Playwright.* packages from your project:

Run the following commands in your terminal

dotnet remove package Microsoft.Playwright

Removes the NUnit integration, if installed

dotnet remove package Microsoft.Playwright.NUnit

Repeat for any other Microsoft.Playwright.* packages in 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 (iOS currently supports Safari).
  • device: Device name (Example: iPhone 16 Pro Max).
  • os_version: iOS 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,warnings for console log verbosity.

Keep version pairs updated when upgrading locally.

Sample C# Android automation script

The given sample script shows how to set preferred devices for running a test. Add this to your existing repo

sample-script.cs
Copy icon Copy

Run the test

Run the given command to execute the test on BrowserStack:

terminal
Copy icon Copy

The test connects to a real Android device, opens Chrome, loads Google, and ends the session.

Run the test

Run the given command to execute the test on BrowserStack:

terminal
Copy icon Copy

The test connects to a real Android device, opens Chrome, loads Google, and ends the session.

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

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle