🪓axe
Accessibility (A11y) Testing with aXe
Usage
The axe fixture is the recommended way to run A11y audits since it's so easy and straightforward.
def test_axe_fixture(py, axe):
py.visit("https://qap.dev")
# save the axe report as a file
report = axe.run(name="a11y_audit.json")
# and/or use the report directly in the test(s)
assert len(report.violations) == 0You can generate the report as a JSON and/or use the AxeReport object directly.
Running an audit will generate a JSON report only if a name is given.
def run(name: str = None, context: Dict = None, options: Dict = None) -> AxeReportArguments
name: strThe file path (including name and.jsonextension) of the report to save as a JSONcontext: DictThe dictionary of page part(s), by CSS Selectors, to include or exclude in the auditoptions: DictThe dictionary of aXe options to include in the audit
Yields
AxeReport - object that represents the audit report in code
If you include the name argument, then that report is also created at the specified file path.
If any of the directories in the path do not exist, then a FileNotFound error is raised.
Last updated