Start and stop App Accessibility scans
Start and stop automated app accessibility scans in your test cases for precise control over what gets scanned.
You can run targeted accessibility checks on specific screens, workflows, or components in your mobile app. This helps you focus testing on the areas that matter most to your users.
The start and stop feature is available only for these frameworks:
- WebdriverIO (WDIO) with the Mocha or Cucumber test runner
- Appium with Java, using JUnit 4, JUnit 5, or TestNG
- Appium with Java, using Cucumber with JUnit 4, Cucumber with JUnit 5, or Cucumber with TestNG
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.
Run targeted scans in your automated tests
App Accessibility Testing runs all scans by default. You can configure your existing functional test automation suite to enable or disable these automatic scans and control when scans start and stop inside your test cases using APIs. You can also use APIs to perform scans at specific points in your test cases.
This page covers the following topics:
- Scan specific sections or points in your test case
- Exclude specific test cases from automated tests
- API reference
- Example usage
Scan specific sections or points in your test case
You can configure your test suites to disable automatic scans and run them only on specific sections or points in your test cases.
In this scenario:
- Automatic scans are completely disabled.
- You can run scans on specific sections of your test case using the start and stop scanning API methods for your framework.
- You can also use the
performScanAPI method to run scans at specific points in the test case.
Build configuration to run scans on specific sections or points
In your functional test automation suite, use the following configuration:
Add these options to your wdio.conf.js file:
...
services: [
['browserstack', {
...
accessibility: true,
accessibilityOptions: {
wcagVersion: 'wcag22aa',
autoScanning: false
}
}]
],
...
Exclude specific test cases from automated tests
You can configure your test suites to run targeted scans by excluding specific test cases from automatic scans. You can also use APIs to control scans at runtime and run scans on specific sections or points in your test cases.
In this scenario:
- Automatic scans are enabled.
- You can exclude specific test cases from the automatic scans using the
excludeTagsInTestingScopeconfiguration. - You can use the start and stop scanning API methods for your framework to run scans manually. These scans include the test cases excluded using
excludeTagsInTestingScope. - You can also use the
performScanAPI method to run scans at specific points in the test case, regardless of the scanning state.
Build configuration to exclude specific test cases
In your functional test automation suite, use the following configuration:
Add these options to your wdio.conf.js file:
...
services: [
['browserstack', {
...
accessibility: true,
accessibilityOptions: {
wcagVersion: 'wcag22aa',
autoScanning: true,
excludeTagsInTestingScope: ["<test1>", "<test2>"] // Test cases with these tags are excluded from automatic scans
}
}]
],
...
API reference
Use these API methods to control scans at runtime. The method names depend on your framework:
For WebdriverIO (WDIO) with the Mocha or Cucumber test runner, use these methods:
-
startA11yScanning()- Enable automatic scans from a specific point in your test case.
- Subsequent eligible commands in your test case trigger scans until you call
stopA11yScanning(). - You can call this API method multiple times in a single test case as needed.
-
stopA11yScanning()- Disable automatic scans from a specific point in your test case.
- Subsequent commands in your test case don’t trigger scans until you call
startA11yScanning()again. - You can call this API method multiple times in a single test case as needed.
-
performScan()- Immediately scan a specific point in the test case.
- Performs the scan regardless of whether automatic scans are enabled or disabled.
- This API method is useful when you want to run a scan on a specific screen or component in your app.
Example usage
These samples start scanning, run a scanned command, stop scanning, and then run a single scan. The samples use the configuration from Scan specific sections or points in your test case, where autoScanning is false.
Add these calls to your test case:
// This sample assumes autoScanning is set to false in your configuration.
await browser.startA11yScanning(); // Eligible commands after this point trigger scans
var loginButton = await $(`~Login`);
await loginButton.click(); // This command is scanned
await browser.stopA11yScanning(); // Commands after this point don't trigger scans
await browser.performScan(); // Runs a single scan, regardless of the scanning state
References
- Define test scope in App Accessibility Automated Tests
- Configuration options for App Accessibility Automated Tests
- Getting started with App Accessibility Automated Tests
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
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!