Skip to content

Commit 3b4edb4

Browse files
Axe HTML Reporting Affected Elements Fix (#43)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> This introduces a temporary fix for the Axe reporting class so it outputs the affected element in the HTML report. It currently just outputs the JSON which isn't the nicest result but at least provides the information required to identify the issue. A more permanent fix will be identified in due course. ## Context <!-- Why is this change required? What problem does it solve? --> At the moment the report highlights the errors, but not where the errors are. This only impacts the HTML report. ## 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. --> - [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 - [ ] I have added tests to cover my changes (where appropriate) - [ ] 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.
1 parent 250ecb1 commit 3b4edb4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

utils/axe.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,15 @@ def details_section(header: str) -> str:
165165
section += f'''<table class="details-section"><tr><th>ID</th><td>{check["id"]}</td></tr>
166166
<tr><th class "details-header">Impact</th><td>{check["impact"]}</td></tr>
167167
<tr><th class "details-header">Tags</th><td>{check["tags"]}</td></tr>
168-
<tr><th class "details-header">Description</th><td>{str(check["description"]).replace("<", "").replace(">", "")}</td></tr>
169-
<tr><th class "details-header">Help</th><td>{str(check["help"]).replace("<", "").replace(">", "")}</td></tr>
170-
<tr><th class "details-header">Help URL</th><td><a href="{check["helpUrl"]}" target="_blank">{check["helpUrl"]}</a></td></tr>
171-
</table><br />'''
168+
<tr><th class "details-header">Description</th><td>{str(check["description"]).replace("<", "&lt;").replace(">", "&rt;")}</td></tr>
169+
<tr><th class "details-header">Help</th><td>{str(check["help"]).replace("<", "&lt;").replace(">", "&rt;")}</td></tr>
170+
<tr><th class "details-header">Help URL</th><td><a href="{check["helpUrl"]}" target="_blank">{check["helpUrl"]}</a></td></tr>'''
171+
172+
if 'nodes' in check:
173+
for node in check['nodes']:
174+
section += f'''<tr><th class "details-header">Affected Node</th><td><code>{str(node).replace("<", "&lt;").replace(">", "&rt;")}</code></td></tr>'''
175+
176+
section += '</table><br />'
172177
else:
173178
section += f'<p>No {header} results returned.</p>'
174179

0 commit comments

Comments
 (0)