AxeRunOptions Klasse

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

Configureer geavanceerde runtime-opties voor toegankelijkheidstests met axe Watcher in Java

Not for use with personal data

De AxeRunOptions klasse biedt configuratie-opties waarmee u kunt bepalen hoe axe-core toegankelijkheidstests uitvoert. Met deze klasse kunt u specifieke regels in- of uitschakelen, beperken welke regels worden uitgevoerd en analysegegevens zoals voorouderinformatie voor toegankelijkheidsschendingen configureren.

Deze opties worden tijdens runtime doorgegeven aan axe-core om het gedrag van de toegankelijkheidsanalysemotor aan te passen.

Constructor

AxeRunOptions()

Maakt een nieuwe instantie van AxeRunOptions met standaardinstellingen. Standaard is de ancestry eigenschap ingesteld op false.

AxeRunOptions options = new AxeRunOptions();

Methoden

setAncestry(boolean ancestry)

Stelt de ancestry eigenschap in. Wanneer ingesteld op true, zal de axe-core motor het volledige CSS-selectorpad opnemen voor elementen met toegankelijkheidsschendingen, inclusief alle bovenliggende elementen. Dit helpt bij het lokaliseren van schendingen in complexe DOM-structuren.

Parameters:

  • ancestry - Booleaanse waarde om voorouderinformatie in of uit te schakelen

Geeft terug:

  • AxeRunOptions - De huidige instantie voor method chaining

Voorbeeld:

AxeRunOptions options = new AxeRunOptions();
options.setAncestry(true);

setRunOnly(AxeRunOnly runOnly)

Stelt de runOnly eigenschap in, waarmee u kunt beperken welke toegankelijkheidsregels worden uitgevoerd. Gebruik dit om testen te richten op specifieke standaarden of regels.

important

U kunt niet zowel runOnly als accessibilityStandard (in ConfigurationOverrides) tegelijkertijd gebruiken.

Parameters:

  • runOnly - Een AxeRunOnly instantie die specificeert welke regels of tags moeten worden uitgevoerd

Geeft terug:

  • AxeRunOptions - De huidige instantie voor method chaining

Voorbeeld:

AxeRunOnly runOnly = new AxeRunOnly()
    .setType("tag")
    .setValues(Arrays.asList("wcag21aa", "best-practice"));

AxeRunOptions options = new AxeRunOptions();
options.setRunOnly(runOnly);

setRules(Map<String, AxeRuleOptions> rules)

Stelt de rules eigenschap in, waarmee u specifieke toegankelijkheidsregels kunt in- of uitschakelen op ID.

Parameters:

  • rules - Een map van regel-ID's naar AxeRuleOptions instanties

Geeft terug:

  • AxeRunOptions - De huidige instantie voor method chaining

Voorbeeld:

Map<String, AxeRuleOptions> rules = new HashMap<>();
rules.put("color-contrast", new AxeRuleOptions().setEnabled(false));
rules.put("aria-roles", new AxeRuleOptions().setEnabled(true));

AxeRunOptions options = new AxeRunOptions();
options.setRules(rules);

getAncestry()

Haalt de huidige waarde van de ancestry eigenschap op.

Geeft terug:

  • boolean - De huidige waarde van de voorouder eigenschap

Voorbeeld:

AxeRunOptions options = new AxeRunOptions();
options.setAncestry(true);
boolean ancestry = options.getAncestry(); // Returns true

getRunOnly()

Haalt de huidige AxeRunOnly configuratie op.

Geeft terug:

  • AxeRunOnly - De huidige runOnly configuratie, of null indien niet ingesteld

Voorbeeld:

AxeRunOptions options = new AxeRunOptions();
AxeRunOnly runOnly = new AxeRunOnly()
    .setType("tag")
    .setValues(Arrays.asList("wcag21aa"));
options.setRunOnly(runOnly);

AxeRunOnly currentRunOnly = options.getRunOnly(); // Returns the runOnly configuration

getRules()

Haalt de huidige map van regelconfiguraties op.

Retourneert:

  • Map<String, AxeRuleOptions> - De huidige regelsconfiguratie, of null indien niet ingesteld

Voorbeeld:

AxeRunOptions options = new AxeRunOptions();
Map<String, AxeRuleOptions> rules = new HashMap<>();
rules.put("color-contrast", new AxeRuleOptions().setEnabled(false));
options.setRules(rules);

Map<String, AxeRuleOptions> currentRules = options.getRules(); // Returns the rules map

toJson()

Serialiseert de AxeRunOptions instantie naar een JSON-string.

Retourneert:

  • String - Een JSON-stringrepresentatie van de opties

Voorbeeld:

AxeRunOptions options = new AxeRunOptions()
    .setAncestry(true)
    .setRunOnly(new AxeRunOnly()
        .setType("tag")
        .setValues(Arrays.asList("wcag21aa")));

String json = options.toJson();
// Returns JSON like: {"ancestry":true,"runOnly":{"type":"tag","values":["wcag21aa"]}}

Notities over configuratievalidatie

Bij het configureren van AxeRunOptions, wees bewust van de volgende validatieregels:

  1. Bij gebruik van setRules():

    • De regelsmap moet ten minste één item bevatten.
    • Elke regelwaarde mag niet null zijn.
  2. Bij gebruik van setRunOnly():

    • De type eigenschap moet een van de volgende zijn: „rule“, „rules“, „tag“ of „tags“
    • De values eigenschap moet ten minste één waarde bevatten
    • De values eigenschap mag geen null-invoeren bevatten
  3. Wederzijds exclusieve configuraties:

    • Je kunt niet zowel runOnly in AxeRunOptions en accessibilityStandard in ConfigurationOverrides tegelijkertijd gebruiken.

Zie ook