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
Connect & Get help from 6000+ developers on our Discord community. Ask the CommunityAsk the Community

Scan a part of a page

Run accessibility scans on a specific section of a page during your automated tests using BrowserStack Accessibility Testing.

By default, BrowserStack Accessibility Testing scans the entire page during your automated tests. You can scope scans to a specific DOM element such as a form, navigation section, or modal by passing a CSS selector to the scan commands. This lets you get precise, component-level accessibility results without noise from unrelated parts of the page.

For example, if your team owns only a certain part of the page and you want to scan only that part for accessibility, you can scope scans to that specific DOM element.

Prerequisites

Before you scan a part of a page, ensure you have:

  • Installed the BrowserStack SDK in your test suite.
  • Enabled accessibility testing in your browserstack.yml file:

    accessibility: true
    
  • Identified the CSS selector that uniquely targets the DOM element you want to scan.

How to scan a part of a page

The first step to scan a part of a page is to set autoScanning: false in your browserstack.yml file.

You can scope accessibility scans to a specific DOM element using either of the following commands:

  • performScan() with a scope argument: Triggers a one-time accessibility scan at a defined step in your test script.
  • startA11yScanning() with a scope argument: Automatically scans a specific DOM element on every DOM mutation within a section of your test. Always pair this with stopA11yScanning(). Supported only for wdio-mocha, wdio-cucumber, and Playwright (Node.js).

Both commands support the following scope argument:

  • includePartOfPageScope: Scans only the specified DOM elements. Pass a CSS selector to scan only that part. You can add only one component in a partial scan. If no scope argument is passed, the command defaults to a full-page scan.

In the current version, if you pass multiple selectors in the includePartOfPageScope array, only the first selector is used for the scan. Support for multiple selectors is planned for a future release.

The includePartOfPageScope value must be a valid CSS selector (such as #main-content). If the selector does not match any element on the page, a report with 0 issues is generated. When multiple elements match the selector, only the first matching element is scanned.

Use performScan() for a one-time scan

To trigger a one-time accessibility scan at a specific step, set autoScanning: false in your browserstack.yml file. If you only want to scan at specific points, then call performScan() with the includePartOfPageScope argument at that step in your test script:

performScan(includePartOfPageScope = ['#main-content > section > div > div > ol > li:nth-child(8)'])

If startA11yScanning() is already running when you call performScan(), both scans are captured and issues are automatically de-duplicated in the report.

After the test run, review the accessibility issues on the Accessibility Testing dashboard.

Use startA11yScanning() for a scoped continuous scan

To automatically scan a specific DOM element on every DOM mutation within a section of your test, call startA11yScanning() with the includePartOfPageScope argument, perform your test interactions, then call stopA11yScanning():

startA11YScanning(includePartOfPageScope = ['#main-content > section > div > div > ol > li:nth-child(8)'])

After the test run, review the accessibility issues on the Accessibility Testing dashboard.

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