2

Hi i'm using the Axe html reporting tool for my script as seen here https://www.npmjs.com/package/axe-html-reporter

Using the code below im getting the error message in the subject title of this ticket.

Im not sure what the issue is?

const AxeBuilder = require('@axe-core/webdriverjs');
const WebDriver = require('selenium-webdriver');
const {By} = require("selenium-webdriver");
const driver = new WebDriver.Builder().forBrowser('chrome').build();
const { createHtmlReport } = require('axe-html-reporter');




(async function(){

    driver.get('https://www.skysports.com/the-hundred')

    // await driver.switchTo().frame(3)
    // await driver.findElement(By.css('button[title=\'Accept\']')).click()
    // await driver.manage().setTimeouts( { implicit: 1000 } )
        .then( () => {
            new AxeBuilder(driver).withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice', 'wcag***', 'act', 'section508', 'section508.*.*', 'experimental', 'cat.*', 'color-contrast'])
                .analyze((err, results) => {
                    if (err) {
                        // Handle error somehow
                    }
                    (() => {
                        (() => {
                            // creates html report with the name `accessibilityReport.html` file
                            createHtmlReport({ results: { violations: 'Result[]' } });
                        })();

                    })();

                });
        });
}());
  • 2
    From the error message, the functoin is expecting that `violations` will be an array, not a string. You've set it to `'Result[]'` (a string). It was probably supposed to be an array of `Result` object. – T.J. Crowder Jul 22 '21 at 11:38
  • Like this? createHtmlReport({ results: { violations: [results] } }); that gives me a new error. HTML report was not created due to the error Cannot read property 'length' of undefined – Peter Kirby Jul 22 '21 at 13:32
  • @T.J.Crowder Im not sure I follow your reply from yesterday – Peter Kirby Jul 23 '21 at 09:35
  • 1
    I haven't used the library you're using. All I can tell you is what I told you above: The error message shows that something is trying to use an array-specific method (`reduce`) on `violations`. In your code in the question, you haven't supplied an array, you've supplied a string. Strings don't have a `reduce` method. I can't tell you why `[results]` didn't work, but notice that the error changed, because you're no longer passing something that isn't an array. So the next step is to find out why that leads to the new error you're getting. I hope you find it! :-) – T.J. Crowder Jul 23 '21 at 09:38
  • 1
    Cheers will investigate a little more. Thanks for replying. – Peter Kirby Jul 23 '21 at 10:16

1 Answers1

0

Getting the same error... But createHtmlReport({ results }) seems to be working fine.

Anna A.
  • 1
  • 1