Axe DevTools for Web Configuratie voor C#

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

Configuratie-informatie en voorbeeldcode voor Axe DevTools for Web voor C#

Not for use with personal data

Dit artikel beschrijft hoe Axe DevTools for Web voor C# geconfigureerd wordt.

Stap 1: Declareer de Selenium-driver om te gebruiken bij het uitvoeren van tests in de C# setup.

[SetUp]
public void Setup()
{
  driver = new ChromeDriver();
  driver.Navigate().GoToUrl("http://abcdcomputech.dequecloud.com/");
}

Stap 2: Specificeer delen van de pagina die je wilt opnemen of uitsluiten van testen.

/*
* TestCase: uses axe.Analyze() to scan the certain content on the page.
*/
[Test]
public void IncludingAndExcludingElements()
{
  var axe = new AxeSelenium(driver).Excluding("#header").Including("#homecontent");
  var results = axe.Analyze();
  Assert.That(results.Findings.Violations.Count, Is.EqualTo(0));
}

Stap 3: Axe DevTools C# bevat een versie van de axe-core JavaScript-bibliotheek. Als alternatief kun je je eigen versie leveren via configuratie.

note

De axe-core bibliotheek verwacht dat je auditsuite zich in je project bevindt op: /config/axe-ruleset.json. Alternatief kun je de locatie specificeren door de AXE_RULESET_PATH omgevingsvariabele in te stellen, direct in de configuratie.

Stap 4: Definieer regels of specifieke regels voor een enkele toegankelijkheidscontrole of voor de gehele testsuite.

/*
 * TestCase: uses axe.Analyze() to scan the page
 * with specific ruleset, in this case 508
*/
[Test]
public void AccessibilityAnalyzeWith508Ruleset()
{
 var axe = new AxeSelenium(driver).WithRuleset("508");
  var results = axe.Analyze();
  AxeReporting.CreateResultsOutput(results, "508-rules");
  Assert.That(results.Findings.Violations.Count, Is.EqualTo(0));
}

/*
 * TestCase: uses axe.Analyze() to scan the page
 * with only the specified rules.
*/
[Test]
public void AccessibilityAnalyzeWithSpecificRules()
{
  var axe = new AxeSelenium(driver).WithRules("heading-order", "link-name");
  var results = axe.Analyze();
  AxeReporting.CreateResultsOutput(results, "specific-rules");
  Assert.That(results.Findings.Violations.Count, Is.EqualTo(0));
}

Zie Aangepaste Regels voor algemene informatie over Schrijven van Regels, Regels, Controles en Resultaten en Regelbeschrijvingen.