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

Start and stop accessibility scans

Start and stop automated accessibility scans in your test cases for precise control over what gets scanned.

This guide explains how you can start and stop automated accessibility scans in BrowserStack Accessibility Testing.

Why control accessibility scans?

Developers and SDETs often need to focus accessibility testing on specific parts of a workflow. By controlling when scans start and stop, you can:

  • Limit scans to relevant sections of your test cases.
  • Avoid reporting issues outside your team’s scope.
  • Optimize test execution and reporting.

How to start and stop accessibility scans

You can use the following commands in your test scripts:

  • startA11yScanning() β€” Starts accessibility scanning (A11Y context).
  • stopA11yScanning() β€” Stops accessibility scanning (A11Y context).

Adding a start command is optional. Multiple start/stop pairs are allowed within a test case. However, each start command should have a corresponding stop command for error-free execution.

Example usage

// ...existing test setup...
startA11yScanning();
// DOM-changing commands here will trigger automatic scans
// ...test steps...
stopA11yScanning();
// Further commands will not trigger automatic scans

Configuration options

Set global config flags in your BrowserStack YAML file:

  • autoScanning: true | false (default: true)

Error handling

  • If a start command is issued without a corresponding stop command, an error will be raised.
  • Scans only run on DOM-changing commands. If you call startA11yScanning() without any DOM change, no scan will be triggered.

Supported combinations

You can use multiple start/stop pairs within a single test case for granular control. Explicit scan statements are supported via the existing performScan method.

Best practices

  • Always pair start and stop commands to avoid errors.
  • Configure global flags in your YAML for team-wide defaults.

How autoScanning and scan commands interact

  • When autoScanning: true is set in your config, accessibility scans run automatically on every page mutation (current default setting).
  • If you use the stopA11yScanning() command, scanning will stopβ€”even if autoScanning is true. The command takes precedence over the config flag.
  • Similarly, if you use startA11yScanning() in a test case, scanning resumes regardless of the global flag or include/exclude settings.
  • The start/stop commands always override the autoScanning, includeTagsInTestingScope, and excludeTagsInTestingScope flags for that test case.

Use cases

Use Case How to Implement
Scan everything except a particular part of the workflow 1. Set autoScanning: true (default setting).
2. When you reach the part to exclude (e.g., a third-party page), call stopA11yScanning().
3. Call startA11yScanning() to resume scanning after the excluded part.
Scan only one part of the workflow 1. Set autoScanning: false.
2. Use startA11yScanning() and stopA11yScanning() around the workflow section to scan.
Scan all test cases except one, but scan a part of the excluded test case 1. Set autoScanning: true.
2. Exclude the specific test case using the excludeTagsInTestingScope flag.
3. Within the excluded test case, use startA11yScanning() and stopA11yScanning() to scan only the desired part.

Start and stop commands always take precedence over global config flags and include/exclude test case settings.

Learn more about automated accessibility tests and configuration options.

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