Sample code for running sessions with MStest on Browserstack using Selenium 4.
To perform tests using Selenium 3, please checkout the selenium 3 branch
To perform tests using SDK, please checkout the sdk branch
MSTest Integration with BrowserStack.
-
Clone the repository.
-
Open the solution
MSTest-BrowserStack.sln
in Visual Studio. -
Install dependencies using NuGet Package Manager:
dotnet restore
-
Build the solution
-
Add your BrowserStack Username and Access Key to the
secrets.json
file in the project. You can follow this guide to learn how to manage secrets.{ "BrowserStackUsername": "your-browserstack-username", "BrowserStackAccessKey": "your-browserstack-access-key" }
-
Alternatively, you can set environment variables:
BROWSERSTACK_USERNAME
BROWSERSTACK_ACCESS_KEY
You can get your browserstack credentials from here
-
To run tests, execute the following command:
dotnet test
-
To run the single test, execute the following command:
dotnet test --filter TestCategory=sample-test
-
To run tests in parallel, execute the following command:
dotnet test --filter TestCategory=sample-parallel-test
-
To run local tests, execute the following command:
dotnet test --filter TestCategory=sample-local-test
Understand how many parallel sessions you need by using our Parallel Test Calculator
-
View your test results on the BrowserStack automate dashboard.
-
For testing on different browsers, check the platform configurator.
-
Export the environment variables for BrowserStack credentials:
export BROWSERSTACK_USERNAME=<browserstack-username> && export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>