Skip to content

Fix generate_report() TypeError for shadow DOM targets - #30

Merged
pamelafox merged 1 commit into
mainfrom
fix-nested-targets
Nov 2, 2026
Merged

pamelafox merged 1 commit into
mainfrom
fix-nested-targets

Conversation

@pamelafox

Copy link
Copy Markdown
Owner

generate_report() crashed with TypeError: sequence item 0: expected str instance, list found when axe reported a node inside shadow DOM, because axe represents those targets as nested selector lists (e.g. [["#host", "button"]]).

Changes

  • Nested targets are now joined as #host >>> button; top-level targets are still joined with , .
  • Added a regression test in tests/test_report_save.py.
  • Verified end-to-end with a real shadow DOM page in Chromium.
  • Added a CHANGELOG entry under Unreleased.

Fixes #19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the shadow DOM selector formatting fix.

No open issues 🎉

What changed in this PR

Fixes the generate_report() crash reported in #19 when axe returns nested selector lists for shadow DOM elements.

Changes:

  • Formats nested selectors with >>> while preserving comma-separated top-level targets.
  • Adds a regression test for shadow DOM target formatting.
  • Documents the fix under Unreleased in the changelog.
File Description
tests/​test_report_save.py Adds a regression test for a nested shadow DOM target.
CHANGELOG.md Records the crash fix and selector display format.
axe_playwright_python/​base.py Handles nested target lists when generating violation reports.

Review effort: Balanced

@pamelafox
pamelafox merged commit 32de414 into main Nov 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generate_report() sometimes gives TypeError: sequence item 0: expected str instance, list found

3 participants