Bird
0
0

How can you exclude a specific element with selector .ad-banner from accessibility checks using cypress-axe?

hard📝 Application Q9 of 15
Cypress - Plugins and Ecosystem
How can you exclude a specific element with selector .ad-banner from accessibility checks using cypress-axe?
Acy.checkA11y('.ad-banner', { exclude: true })
Bcy.checkA11y(null, { include: ['.ad-banner'] })
Ccy.injectAxe({ exclude: ['.ad-banner'] }) cy.checkA11y()
Dcy.injectAxe() cy.checkA11y(null, { exclude: ['.ad-banner'] })
Step-by-Step Solution
Solution:
  1. Step 1: Learn how to exclude elements in checkA11y

    The exclude option takes an array of selectors to skip during accessibility checks.
  2. Step 2: Confirm correct usage

    Inject axe first, then call checkA11y with null for whole page and exclude option.
  3. Final Answer:

    cy.injectAxe() cy.checkA11y(null, { exclude: ['.ad-banner'] }) -> Option D
  4. Quick Check:

    Use exclude option with selectors to skip elements [OK]
Quick Trick: Use exclude option to skip elements in accessibility checks [OK]
Common Mistakes:
  • Passing exclude to injectAxe instead of checkA11y
  • Using include instead of exclude to skip elements
  • Trying to exclude by checking only that element

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes