public void TestAccessibilityOfPageExcludingKnownIssues()

in csharp-selenium-webdriver-sample/SamplePageTests.cs [95:123]


        public void TestAccessibilityOfPageExcludingKnownIssues()
        {
            // You can use AxeBuilder.Exclude to exclude individual elements with known issues from a scan.
            //
            // Exclude accepts any CSS selector; you could also use ".some-classname" or "div[some-attr='some value']"
            AxeResult axeResultExcludingExampleViolationsElement = new AxeBuilder(_webDriver)
                .Exclude("#id-of-example-accessibility-violation-list")
                .Analyze();
            
            axeResultExcludingExampleViolationsElement.Error.Should().BeNull();
            axeResultExcludingExampleViolationsElement.Violations.Should().BeEmpty();

            // You can also use AxeBuilder.DisableRules to exclude certain individual rules from a scan. This is particularly
            // useful if you still want to perform *some* scanning on the elements you exclude from more broad scans.
            AxeResult axeResultDisablingRulesViolatedByExamples = new AxeBuilder(_webDriver)
                .Include("#id-of-example-accessibility-violation-list") // Like Exclude(), accepts any CSS selector
                .DisableRules("color-contrast", "label", "tabindex")
                .Analyze();

            axeResultDisablingRulesViolatedByExamples.Error.Should().BeNull();
            axeResultDisablingRulesViolatedByExamples.Violations.Should().BeEmpty();

            // Another option is to assert on the size of the Violations array. This works just fine, but we recommend the
            // other options above as your first choice instead because when they do find new issues, they will produce error
            // messages that more clearly identify exactly what the new/unexpected issues are.
            AxeResult axeResult = new AxeBuilder(_webDriver).Analyze();
            axeResult.Error.Should().BeNull();
            axeResult.Violations.Should().HaveCount(3);
        }