Generating Reports With Python
Axe::analyze returns an object in the right shape for use with the Axe DevTools reporter. It can
be converted to a JSON string via the
Here is an example where we analyze a page and save the results to a file:
axe = Axe(driver) results = axe.analyze() with open("my_results.json", "w") as f: f.write(results.to_json())
Report metadata is configured via the
ReportConfiguration class. See below for methods to
ReportConfiguration object is in the desired state, it can be applied to a scan in two
It can be applied to a single scan by tying it to a single
report_config = ReportConfiguration().test_suite_name("my suite").ui_state("some state") axe = Axe(driver, report_configuration=report_config) results = axe.analyze() assert results.name == "my suite" assert results.id = "some state"
It can be applied to all scans that are not individually overridden, by setting an instance of
ReportConfigurationas the default
ReportConfiguration().test_suite_name("my suite").set_as_default() axe = Axe(driver) results = axe.analyze() assert results.name == "my suite"
You can get the
ReportConfiguration instance currently serving as the default by calling
@staticmethod def get_default(): """Gets the current default configuration. Note that the default can be changed. Returns: The current default """
def set_as_default(self): """Sets this object as the default"""
@staticmethod def reset_default(): """Resets the default to its initial state"""
def test_suite_name(self, name): """Sets the test suite name Args: name: The name Returns: This object for chaining """
def ui_state(self, id): """Specify the ui-state for this set of tests. Used as ID. Args: id: State id Returns: This object for chaining """
def user_agent(self, ua): """Set the user agent used when testing Args: ua: The user agent string Returns: This object for chaining """
def test_machine(self, t_machine): """Sets the machine the tests were run on Args: t_machine: Id for the machine Returns: This object for chaining """
- Uploading JSON Accessibility Results to axe Reports describes how to upload your results to axe Reports.
- Obtaining an axe Reports API Key tells how to obtain an API key to begin using axe Reports.
- Creating and Filtering Reports shows how you can create accessibility reports in CSV, XML, or HTML from your JSON accessibility results. You can also filter your output by severity using this tool.
- How JSON Results are Stored on Disk describes the file naming conventions for JSON accessibility results.