Skip to main content
🎉 A11y Issue Detection Agent is now live! Detect accessibility issues like a WCAG expert with AI. Try now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Run accessibility checks on the MSTest sample repository

Run automated App Accessibility checks on real devices using the BrowserStack sample MSTest repository.

BrowserStack App Automate supports running MSTest tests on a wide range of real Android and iOS devices. Use the BrowserStack sample repository to run your first MSTest build with accessibility checks enabled.

For Android devices, automated App Accessibility testing is supported on version 11 and above.

Prerequisites

  • Ensure you have a BrowserStack Username and Access Key. Obtain your userName and accessKey from the Account & Profile section on the dashboard.
    If you have not yet created an account, sign up for a free trial.
  • .NET 6.0 or later.

Run a sample build

Get the sample project

The BrowserStack sample MSTest project keeps its SDK-based setup on the sdk branch. Clone that branch using the following command:

Copy icon Copy

Navigate to the cloned project directory:

Copy icon Copy

Set your BrowserStack credentials

The sample project reads your credentials from environment variables. Save your credentials so you can run the suite from your local or CI environment.

Set the following values in either your Zsh (~/.zprofile) or Bash (~/.profile) shell configuration file.

export BROWSERSTACK_USERNAME=YOUR_USERNAME
export BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY

The sample project holds a separate directory and configuration file for each platform. Based on the platform you want to test, navigate to the corresponding directory.

Copy icon Copy

Update the BrowserStack SDK

From the platform directory, run the following command to update the SDK to the current version.

Copy icon Copy

The sample project pins an older BrowserStack.TestAdapter version that doesn’t work on current .NET runtimes. Without this command, the project still builds, but the test run stops with a HarmonyException before reaching BrowserStack. This command updates the adapter and the browserstack-sdk command line tool to the current version.

Modify the configuration file

Each platform directory has its own browserstack.yml file, which defines the capabilities used to run your tests on BrowserStack. Edit the file in your platform directory, as follows:

  1. Open the browserstack.yml file.
  2. Set framework to mstest.
  3. Set accessibility to true. The default value is false.
  4. Set browserstackLocal to false. The sample project sets browserstackLocal to true for its Local Testing example, which accessibility tests don’t use.
  5. If you’re running Android tests, delete the name property. The Android .yml file sets name: BStack android test, which the SDK sends to BrowserStack as a capability. BrowserStack rejects that capability, and your test session never starts.
  6. Check every device and OS version under platforms against the list of supported devices, and replace any that BrowserStack no longer offers. The sample project pins older combinations, and one unsupported entry fails the whole run.
  7. Set the accessibility testing options you need under accessibilityOptions. For the full list, see Configuration options.
  8. Save the file.

To auto-generate screen reader testing reports for your app’s workflow, set the screenReaderAutomationReport flag to true under accessibilityOptions.

The projectName and buildName config must be static and not change across different runs of the same build. This is a deviation in approach as specified by BrowserStack App Automate since Automated tests will automatically identify different build runs.

Android/browserstack.yml
Copy icon Copy

Run the sample test

From the platform directory, run the following command:

Copy icon Copy

The SingleTest filter runs the sample accessibility test. The sample project also includes a Local Testing example, which needs a BrowserStack Local tunnel and isn’t part of this guide.

The sample project was built for .NET 6, so .NET requires the .NET 6 runtime to run the project. Without that runtime, the run stops with a Framework: 'Microsoft.NETCore.App', version '6.0.0' error before the test reaches BrowserStack. Setting DOTNET_ROLL_FORWARD to Major runs the project on the newest runtime you have, so you don’t need to install .NET 6.

View the accessibility test report

After the test run completes, open the App Accessibility dashboard to review the violations found in each scan.


Visit App Accessibility dashboard

Next steps

To add accessibility checks to your own test suite, see Integrate MSTest test suite with App Accessibility testing.

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