Skip to content

When deserialising the generated axe-core results the target selector is a producing a string and not a string[] #217

@Zidious

Description

@Zidious

Thank you for reporting an issue with one of our packages. Please provide all necessary information to reproduce the issue to assist with investigation

Which package were you using when you encountered the issue?**

  • Deque.AxeCore.Selenium
  • Deque.AxeCore.Playwright
  • Deque.AxeCore.Commons

Describe the bug

When logging out or saving the results via toString() the axe-core results are incorrectly deserialising the node[0].target as a string and not List<string> resulting in inconsistencies with axe-core and other integrations.

How to reproduce

Example test script:

using Deque.AxeCore.Commons;
using Deque.AxeCore.Playwright;
using Microsoft.Playwright;
using Newtonsoft.Json;


class Program
{
    public static async Task Main()
    {
        using var playwright = await Playwright.CreateAsync();
        await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
        {
            Headless = false
        });

        var context = await browser.NewContextAsync();
        var page = await context.NewPageAsync();


        await page.GotoAsync("https://dequeuniversity.com/demo/mars/");


        AxeResult result = await page.RunAxe();
        Console.WriteLine(result.Violations[0].Nodes[0].Target);
        await File.WriteAllTextAsync("./axe-results.json", result.ToString());


        await browser.CloseAsync();
    }
}

The generated axe-results show target as a string and not string[]:

  "violations": [
    {
      "id": "button-name",
      "description": "Ensure buttons have discernible text",
      "help": "Buttons must have discernible text",
      "helpUrl": "https://dequeuniversity.com/rules/axe/4.10/button-name?application=axe-core-playwright-nuget",
      "impact": "critical",
      "tags": [
        "cat.name-role-value",
        "wcag2a",
        "wcag412",
        "section508",
        "section508.22.a",
        "TTv5",
        "TT6.a",
        "EN-301-549",
        "EN-9.4.1.2",
        "ACT"
      ],
      "nodes": [
        {
          "target": ".departure-date > .ui-datepicker-trigger:nth-child(4)",
          "xPath": null,
          "ancestry": null,
          "html": "<button class=\"ui-datepicker-trigger\" type=\"button\">\n<!-- <img title=\"...\" alt=\"...\" src=\"/redesign/assets/demo-sites/mars/images/calendar.png\"> -->\n</button>",
          "impact": "critical",
          "any": [
            {
              "data": null,
              "id": "button-has-visible-text",
              "impact": "critical",
              "message": "Element does not have inner text that is visible to screen readers",
              "relatedNodes": []
            },
            {
              "data": null,
              "id": "aria-label",
              "impact": "critical",
              "message": "aria-label attribute does not exist or is empty",
              "relatedNodes": []
            },
            {
              "data": null,
              "id": "aria-labelledby",
              "impact": "critical",
              "message": "aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty",
              "relatedNodes": []
            },
            {
              "data": {
                "messageKey": "noAttr"
              },
              "id": "non-empty-title",
              "impact": "critical",
              "message": "Element has no title attribute",
              "relatedNodes": []
            },
            {
              "data": null,
              "id": "implicit-label",
              "impact": "critical",
              "message": "Element does not have an implicit (wrapped) <label>",
              "relatedNodes": []
            },
            {
              "data": null,
              "id": "explicit-label",
              "impact": "critical",
              "message": "Element does not have an explicit <label>",
              "relatedNodes": []
            },
            {
              "data": null,
              "id": "presentational-role",
              "impact": "critical",
              "message": "Element's default semantics were not overridden with role=\"none\" or role=\"presentation\"",
              "relatedNodes": []
            }
          ],
          "all": [],
          "none": []
        }
      ]
    }
]

Expected behavior

target should be consistent with what axe-core produces which is either a list of strings or list of list of strings for iframes.

Device Information

  • OS: Mac
  • Browser: Chrome
  • Deque.AxeCore.* Package Version(s): latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions