How to use the axe-core.source function in axe-core

To help you get started, we’ve selected a few axe-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sitespeedio / sitespeed.io / lib / plugins / axe / axePostScript.js View on Github external
module.exports = async function(context) {
  // Insert the axe source
  await context.selenium.driver.executeScript(axe);

  // Only configure if we have more keys thhan axe.enable
  if (context.options.axe && Object.keys(context.options.axe).length > 1) {
    await context.selenium.driver.executeScript(
      'axe.configure(' + JSON.stringify(context.options.axe) + ');'
    );
  }

  // Get the result from axe
  const result = await context.selenium.driver.executeAsyncScript(
    'window.axe.run().then(arguments[arguments.length - 1]);'
  );

  // Use the extras field in Browsertime and pass on the result
  context.result[context.result.length - 1].extras.axe = result;
};
github linode / manager / packages / manager / e2e / utils / accessibility.js View on Github external
export const axeTest = () => {
  browser.execute(axeSource);

  const testResults = browser.executeAsync(function(done) {
    axe.run(function(err, results) {
      done(results);
    });
  });

  return testResults.value.violations;
};