Skip to content

Commit

Permalink
WCAG 2.2 Implementation in Axe Util (#31)
Browse files Browse the repository at this point in the history
<!-- markdownlint-disable-next-line first-line-heading -->
## Description

<!-- Describe your changes in detail. -->
WCAG 2.2 AA Implementation in Axe Utility - was previously only scanning
up to 2.1 AA.

## Context

<!-- Why is this change required? What problem does it solve? -->
Matches the correct standard.

## Type of changes

<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply. -->

- [ ] Refactoring (non-breaking change)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would change existing
functionality)
- [x] 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. -->

- [ ] I am familiar with the [contributing
guidelines](../docs/CONTRIBUTING.md)
- [x] I have followed the code style of the project
- [ ] I have added tests to cover my changes
- [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.
  • Loading branch information
davethepunkyone authored Nov 10, 2024
1 parent 01245c6 commit bb7da0d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/utility-guides/Axe.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The `Axe.run(page)` has the following optional arguments that can be passed in:

|Argument|Format|Supported Values|Default Value|Description|
|--------|------|----------------|-------------|-----------|
|`ruleset` |`list[str]`|Any provided by [axe-core](https://www.deque.com/axe/core-documentation/api-documentation/)|`['wcag2a', 'wcag21a', 'wcag2aa', 'wcag21aa', 'best-practice']`|The tags that axe-core uses to filter specific checks. Defaulted to rules used for the WCAG 2.2 AA standard.|
|`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.|
|`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.|
|`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.|
|`strict_mode`|`bool`|`True`, `False`|`False`|If True, when a violation is found an AxeAccessibilityException is raised, causing a test failure.|
Expand Down
2 changes: 1 addition & 1 deletion tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_basic_example(page: Page) -> None:
# Assert repo text is present
expect(page.get_by_role("article")).to_contain_text("Playwright Python Blueprint")

# Assert the page loaded is the playwright-python topic page
# Assert the page loaded contains a reference to the playwright-python topic page
expect(page.get_by_role("main")).to_contain_text("playwright-python")


Expand Down
4 changes: 2 additions & 2 deletions utils/axe.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Axe:
@staticmethod
def run(page: Page,
filename: str = "",
ruleset: list = ['wcag2a', 'wcag21a', 'wcag2aa', 'wcag21aa', 'best-practice'],
ruleset: list = ['wcag2a', 'wcag21a', 'wcag2aa', 'wcag21aa', 'wcag22a', 'wcag22aa', 'best-practice'],
report_on_violation_only: bool = False,
strict_mode: bool = False,
html_report_generated: bool = True,
Expand All @@ -30,7 +30,7 @@ def run(page: Page,
Args:
page (playwright.sync_api.Page): The page object to execute axe-core against.
filename (str): The filename to use for the outputted reports. If not provided, defaults to the URL under test.
ruleset (list[str]): [Optional] If provided, a list of strings to denote the ruleset tags axe-core should use. If not provided, defaults to the WCAG 2.2 AA standard (uses tags: 'wcag2a', 'wcag21a', 'wcag2aa', 'wcag21aa', 'best-practice').
ruleset (list[str]): [Optional] If provided, a list of strings to denote the ruleset tags axe-core should use. If not provided, defaults to the WCAG 2.2 AA standard (uses tags: 'wcag2a', 'wcag21a', 'wcag2aa', 'wcag21aa', 'wcag22a', 'wcag22aa', 'best-practice').
report_on_violation_only (bool): [Optional] If true, only generates an Axe report if a violation is detected. If false (default), always generate a report.
strict_mode (bool): [Optional] If true, raise an exception if a violation is detected. If false (default), proceed with test execution.
html_report_generated (bool): [Optional] If true (default), generates a html report for the page scanned. If false, no html report is generated.
Expand Down

0 comments on commit bb7da0d

Please sign in to comment.