IsaacWalker/PlaywrightAxeDotnet

Unable to scan using Playwright.Net version 1.23

Closed this issue · 2 comments

Using Playwright.Net 1.23, when I hit my line of code that scans the page for accessibility issues I get the exception:

System.Text.Json.JsonException: 'The JSON value could not be converted to System.Collections.Generic.IList`1[System.String]. Path: $.incomplete[0].tags | LineNumber: 0 | BytePositionInLine: 40253.'

If I downgrade to Playwright.Net version 1.22 everything works fine again.

This is my method for scanning:

    public async Task<AxeResults> GetAccessibilityAxeResults()
    {
        IList<string> tags = _settings.AxeTags ?? new List<string>() { "wcag2aa", "wcag2a" };
        IList<AxeResultGroup> resultTypes = new List<AxeResultGroup> { AxeResultGroup.Violations };
        var options = new AxeRunOptions(
                runOnly: new AxeRunOnly(AxeRunOnlyType.Tag, tags),
                resultTypes: resultTypes,
                iframes: false
            );
        var reportOptions = new AxeHtmlReportOptions(reportDir: $"{Defaults.OutputFolder}\\AxeReports");
        //This next line breaks with Playwright 1.23
        **var results = await (await _page).RunAxe(options, reportOptions);**
        Log.Info($"Found {results.Violations.Count} accessibility violations for url [{results.Url}]");
        return results;
    }

Thanks, it's related to Playwright enabling recursive objects in v1.23.0.

I've added a temporary fix to 1.2.0 which seems to do the trick while I dig deeper.

Let me know if it fixes the issue for you.

Hi, that's great, it all seems to be working nicely again now. Thanks for the super quick fix!