Test localhost and staging websites that are not publicly accessible
BrowserStack can integrate with test suites pointing to your localhost URL, staging environment, and even websites behind one or more proxies/firewalls. This is done using BrowserStack Local - a tunneling feature that establishes a secure connection between your machine and the BrowserStack Cloud.
Select your integration method
-
BrowserStack SDK (Recommended)Plug-n-play solution that takes care of all the integration steps for you
-
Legacy (Language bindings)Start and stop the BrowserStack Local tunnel within your test suite manually
Using the BrowserStack SDK is the recommended integration method for C#. The SDK handles your integration steps automatically.
Prerequisites
-
If you have already run your first test, you can skip the 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.
Run your first local test
Configure your C# tests for Local Testing using the following steps:
Clone the csharp-browserstack sample repo on GitHub using the following command:
Open the PlaywrightDotnetTests.csproj
file and verify the BrowserStackLocal
and NuGet packages
are added to it:
Compile the source code of the project by running the following command:
Update your config file in your sample repository to set your BrowserStack Username and Access Key.
Verify that the BrowserstackLocal
capability is set to true
:
Run your C# test using BrowserStack Local with the following command:
View your tests on BrowserStack on the BrowserStack Automate Dashboard.
Understand your local test script
When you run the dotnet run local
command, the LocalTest.cs
file within the CSharp-Playwright-BrowserStack/LocalTest.cs
directory is executed.
When the test is triggered, it:
- Opens the
http://bs-local.com:45454/check
website. - Checks whether the web page displays the
Up and running
text. - Marks the test as passed or failed based on whether the text is displayed on the web page.
Next steps
After you have successfully run your first test using BrowserStack Local, you can explore the following sections:
- Run Playwright tests on your privately hosted websites
- Testing your local site that might be behind a proxy
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!