1

I am trying to integrate accessibility tests with a my automation tests. I ran a basic tests with tags wcag21aa and wcag2aa. However test results shows me passes from only 2 rule i.e. "color-contrast" and "Inline text spacing must be adjustable with custom stylesheets", even though I have not defined any rule in the run.

AxeResult axeResult = new AxeBuilder(webDriver)
.WithTags("wcag2a","wcag21aa")
.Analyze();

How can I get the complete report having all the rules which passed

DevX
  • 490
  • 6
  • 23

1 Answers1

0

I came across the same issue and this is what works for me:

AxeResult result = Driver.Analyze();
            var resultJson = JsonConvert.SerializeObject(result, Formatting.Indented);
            Assert.True(string.IsNullOrEmpty(result.Error) && result.Violations.Length == 0, "Failures:" + resultJson);

Using this will include Axe "best practice" rules which you may or may not want to run depending on your requirements. Importantly, the inclusion of the JSON logic will return a log of each violation, passed rules, incomplete and inapplicable.

I like using this logic as it allows you to scan the whole page and includes any actions needed to rectify violations within the JSON.