Skip to content

API

base.AxeBase(axe_script=AXE_SCRIPT)

Bases: ABC

Abstract base class.

Parameters:

  • axe_script (str) –

    axe.js or axe.min.js javascript. Defaults to AXE_SCRIPT.

from_file(axe_min_js_path) classmethod

Load axe script from file and create Axe instance.

Parameters:

  • axe_min_js_path (str | Path) –

    path to axe.js or axe.min.js

Returns:

  • AxeBase( AxeBase ) –

    Axe instance

base.AxeResults(response)

violations_count: int property

Number of violations found.

generate_report(violation_id=None)

Return readable report of accessibility violations found. Defaults to all violations, but can be filtered by violation ID. @param violation_id: Violation ID to report on

generate_snapshot()

Return snapshot of violations, for use in snapshot testing. Format: (impact) :

save_to_file(file_path=None, violations_only=False)

Save results to file. @param results: Results from Axe analysis @param file_path: File path for saving results file

sync_playwright.Axe

Bases: AxeBase

run(page, context=None, options=DEFAULT_OPTIONS)

Run axe accessibility checks against webpage.

Parameters:

  • page (playwright.sync_api._generated.Page) –

    Page object

  • context (str | list | dict | None) –

    context. Defaults to None.

  • options (dict | None) –

    options. Defaults to {"resultTypes": ["violations"]}.

For more information on context and options, view the axe-core documentation.

Returns:

  • dict( AxeResults ) –

    test result

async_playwright.Axe

Bases: AxeBase

run(page, context=None, options=DEFAULT_OPTIONS) async

Asynchronously run axe accessibility checks against webpage.

Parameters:

  • page (playwright.async_api.Page) –

    Page object

  • context (str | list | dict | None) –

    context. Defaults to None.

  • options (dict | None) –

    options. Defaults to {"resultTypes": ["violations"]}

For more information on context and options, view the axe-core documentation.

Returns:

  • dict( AxeResults ) –

    test result