You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change to Axe class to use pytest-playwright-axe instead (#45)
<!-- markdownlint-disable-next-line first-line-heading -->
## Description
<!-- Describe your changes in detail. -->
This changes the logic of the Axe utility to use the dedicated
pytest-playwright-axe package instead.
## Context
<!-- Why is this change required? What problem does it solve? -->
This removes the project dependency on Axe to a more appropriate
location, and brings in enhanced HTML reporting and functionality.
## Type of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply. -->
- [x] Refactoring (non-breaking change)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would change existing
functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I am familiar with the [contributing
guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md)
- [x] I have followed the code style of the project
- [x] I have added tests to cover my changes (where appropriate)
- [x] I have updated the documentation accordingly
- [ ] This PR is a result of pair or mob programming
---
## Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others
privacy, we kindly ask you to NOT including [PII (Personal Identifiable
Information) / PID (Personal Identifiable
Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public)
or any other sensitive data in this PR (Pull Request) and the codebase
changes. We will remove any PR that do contain any sensitive
information. We really appreciate your cooperation in this matter.
- [x] I confirm that neither PII/PID nor sensitive data are included in
this PR and the codebase changes.
Copy file name to clipboardExpand all lines: docs/utility-guides/Axe.md
+8-55Lines changed: 8 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,20 +3,18 @@
3
3
The Axe utility provided by this blueprint allows for the scanning of pages by using [axe-core](https://github.com/dequelabs/axe-core), a JavaScript
4
4
library used for scanning for accessibility issues and providing guidance on how to resolve these issues.
5
5
6
+
> NOTE: This is now a direct extension of the [pytest-playwright-axe](https://github.com/davethepunkyone/pytest-playwright-axe) plugin with logic to apply WCAG 2.2 AA rules by default.
7
+
6
8
## Table of Contents
7
9
8
10
-[Utility Guide: Axe](#utility-guide-axe)
9
11
-[Table of Contents](#table-of-contents)
10
12
-[Using the Axe class](#using-the-axe-class)
11
13
-[.run(): Single page scan](#run-single-page-scan)
@@ -43,30 +41,9 @@ By default, the `Axe.run(page)` command will do the following:
43
41
- Any steps after the `Axe.run()` command will continue to execute, and it will not cause the test in progress to fail (it runs a passive scan of the page)
44
42
- Will return the full response from axe-core as a dict object if the call is set to a variable, e.g. `axe_results = Axe.run(page)` will populate `axe_results` to interact with as required
|`ruleset`|`list[str]`| Any provided by [axe-core](https://www.deque.com/axe/core-documentation/api-documentation/)|`['wcag2a', 'wcag21a', 'wcag2aa', 'wcag21aa', 'wcag22a', 'wcag22aa', 'best-practice']`| The tags that axe-core uses to filter specific checks. Defaulted to rules used for the WCAG 2.2 AA standard. |
61
-
|`filename`|`str`| A string valid for a filename (e.g. `test_report`) || If provided, HTML and JSON reports will save with the filename provided. If not provided (default), the URL of the page under test will be used as the filename. |
62
-
|`report_on_violation_only`|`bool`|`True`, `False`|`False`| If True, HTML and JSON reports will only be generated if at least one violation is found. |
63
-
|`strict_mode`|`bool`|`True`, `False`|`False`| If True, when a violation is found an AxeAccessibilityException is raised, causing a test failure. |
64
-
|`html_report_generated`|`bool`|`True`, `False`|`True`| If True, a HTML report will be generated summarising the axe-core findings. |
65
-
|`json_report_generated`|`bool`|`True`, `False`|`True`| If True, a JSON report will be generated with the full axe-core findings. |
66
-
67
-
### Returns
44
+
### Further reading
68
45
69
-
This function can be used independently, but when set to a variable returns a `dict` with the axe-core results.
46
+
This class directly extends the pytest-playwright-axe plugin version of this function, so please see the [single page scan documentation](https://github.com/davethepunkyone/pytest-playwright-axe?tab=readme-ov-file#run-single-page-scan) for additional arguments that can be used.
70
47
71
48
### Example usage
72
49
@@ -85,33 +62,9 @@ To scan multiple URLs within your application, you can use the following method:
85
62
86
63
This runs the `Axe.run()` function noted above against each URL provided in the `page_list` argument, and will generate reports as required.
| page | playwright.sync_api.Page | A Playwright Page object to drive navigation to each page to test. |
95
-
| page_list | list[str]| A list of URLs to execute against |
96
-
97
-
> NOTE: It is heavily recommended that when using the `run_list` command, that you set a `--base-url` either via the pytest.ini file or by passing in the value when using the `pytest` command in the command line. By doing this, the list you pass in will not need to contain the base URL value and therefore make any scanning transferrable between environments.
98
-
99
-
### Optional arguments
100
-
101
-
The `Axe.run_list(page, page_list)` function has the following optional arguments that can be passed in:
102
-
103
-
| Argument | Format | Supported Values | Default Value | Description |
|`use_list_for_filename`|`bool`|`True`, `False`|`True`| If True, the filename will be derived from the value provided in the list. If False, the full URL will be used. |
106
-
|`ruleset`|`list[str]`| Any provided by [axe-core](https://www.deque.com/axe/core-documentation/api-documentation/)|`['wcag2a', 'wcag21a', 'wcag2aa', 'wcag21aa', 'wcag22a', 'wcag22aa', 'best-practice']`| The tags that axe-core uses to filter specific checks. Defaulted to rules used for the WCAG 2.2 AA standard. |
107
-
|`report_on_violation_only`|`bool`|`True`, `False`|`False`| If True, HTML and JSON reports will only be generated if at least one violation is found. |
108
-
|`strict_mode`|`bool`|`True`, `False`|`False`| If True, when a violation is found an AxeAccessibilityException is raised, causing a test failure. |
109
-
|`html_report_generated`|`bool`|`True`, `False`|`True`| If True, a HTML report will be generated summarising the axe-core findings. |
110
-
|`json_report_generated`|`bool`|`True`, `False`|`True`| If True, a JSON report will be generated with the full axe-core findings. |
111
-
112
-
### Returns
65
+
### Further reading
113
66
114
-
This function can be used independently, but when set to a variable returns a `dict` with the axe-core results for all pages scanned (using the URL value in the list provided as the key).
67
+
This class directly extends the pytest-playwright-axe plugin version of this function, so please see the [multiple page scan documentation](https://github.com/davethepunkyone/pytest-playwright-axe?tab=readme-ov-file#run_list-multiple-page-scan)for additional arguments that can be used.
0 commit comments