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 configuratieopties die bepalen hoe axe-core toegankelijkheidstests uitvoert. Deze klasse stelt je in staat specifieke regels in of uit te schakelen, te beperken welke regels worden uitgevoerd, en details van de analyse te configureren, zoals voorouderinformatie voor toegankelijkheidsfouten.

Deze opties worden tijdens de runtime aan axe-core doorgegeven om het gedrag van de toegankelijkheidsanalyse-engine 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 engine het volledige CSS-selectorpaden voor elementen met toegankelijkheidsfouten opnemen, inclusief alle bovenliggende elementen. Dit helpt bij het lokaliseren van fouten in complexe DOM-structuren.

Parameters:

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

Retourneert:

  • AxeRunOptions - De huidige instantie voor method chaining

Voorbeeld:

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

setRunOnly(AxeRunOnly runOnly)

Stelt de runOnly eigenschap in, waarmee je kunt beperken welke toegankelijkheidsregels worden uitgevoerd. Gebruik dit om tests te richten op specifieke standaarden of regelsets.

important

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

Parameters:

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

Retourneert:

  • 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 je specifieke toegankelijkheidsregels per ID kunt in- of uitschakelen.

Parameters:

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

Retourneert:

  • 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()

Verkrijgt de huidige waarde van de ancestry eigenschap.

Retourneert:

  • boolean - De huidige waarde van de vooroudereigenschap

Voorbeeld:

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

getRunOnly()

Verkrijgt de huidige AxeRunOnly configuratie.

Retourneert:

  • 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()

Verkrijgt de huidige kaart van regelconfiguraties.

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"]}}

Validatienotities voor configuratie

Houd bij het configureren van AxeRunOptions rekening met de volgende validatieregels:

  1. Bij gebruik van setRules():

    • De regels kaart moet ten minste één item bevatten.
    • Elke regelwaarde kan 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 minstens één waarde bevatten
    • De eigenschap values kan geen lege waarden bevatten
  3. Wederzijds exclusieve configuraties:

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

Zie ook