dequelabs / axe-core-npm

Mozilla Public License 2.0
591 stars 67 forks source link

Trying to generate JSON-LD encoded EARL report using Webdriverjs #88

Open adilsofficial opened 5 years ago

adilsofficial commented 5 years ago

I'm trying to generate the earl format result using axe earl reporter with webdriverjs, but unable to do that as there is no API documentation for this reporter. var earlResults = reporter.createEarlReport(results); console.log(earlResults); Is there another way to call the reporter function to generate the earl reports?

WilcoFiers commented 5 years ago

Thanks for reporting this. Unfortunately this currently isn't possible to do. The way this should work, is through the new raw-env reporter that was added to axe-core in 3.3.0. We haven't gotten around to adopting this pattern in axe-reporter-earl yet. This is how it should work:

const AxeBuilder = require('axe-webdriverjs');
const { createEarlReport } = require('axe-reporter-earl');
const WebDriver = require('selenium-webdriver');

const driver = new WebDriver.Builder()
  .forBrowser('chrome')
  .build();

driver
  .get('https://dequeuniversity.com/demo/mars/')
  .then(() =>  {
    AxeBuilder(driver)
      // Get raw results, to pass along to the earl reporter
      .options({ reporter: 'rawEnv' })
      .analyze((err, results) => {
        if (err) {
          console.error(err);
        }
        console.log(createEarlReport(results));
        driver.quit();
      });
  });

We haven't added support for rawEnv to axe-reporter-earl yet, although you are welcome to submit a pull request if you'd like.

adilsofficial commented 5 years ago

I tried to use this way found an error that createEarlReporter is not a function. Also 'rawEnv' is not a parameter mentioned in API documentation you referred me.

jeeyyy commented 3 years ago

@adilsofficial thanks for reporting this.

We have moved this package to be under our axe-core-npm monorepo for easier management. As a result, this repository will be deprecated in the coming weeks.

I will transfer this issue to the axe-core-npm repository.

You are welcome to contribute.

wonderfulspam commented 3 years ago

Any news on this? I have a similar use case: I'm trying to combine @axe-core/puppeteer and @axe-core/reporterEarl and not having much luck.

await page.goto(url);
await new AxePuppeteer(page).options( // Changing .options() to .configure() makes no difference
    {
        reporter: "rawEnv",
    }
).analyze(function(err, res) {
    console.log(err); // prints "null"
    console.log(res); // prints "undefined"
    console.log(createEarlReport(res)); // Fails because res is undefined
});
await page.close();

I'm not sure whether this is simply impossible or if I'm going about it the wrong way. Would it be possible to provide a self-contained example of integrating @axe-core/reporterEarl in one of the other axe-core-npm packages?