Skip to content

feat(plugins): sitemap plugin collecting visited pages - #5744

Open
DavertMik wants to merge 2 commits into
4.xfrom
feat/sitemap-plugin
Open

DavertMik wants to merge 2 commits into
4.xfrom
feat/sitemap-plugin

Conversation

@DavertMik

@DavertMik DavertMik commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Adds a sitemap plugin that collects all pages visited while tests run and saves them as output/sitemap.xml (sitemap protocol).

plugins: {
  sitemap: { enabled: true }
}

or npx codeceptjs run -p sitemap

How it works

Listeners are attached once per browser instance on test.started. Nothing is added to test steps:

  • Playwright: browser.on('context') → context.on('page'), so contexts created later by session() are covered. Each page records its URL on load, and on main-frame framenavigated for history.pushState routes.
  • Puppeteer: browser.on('targetcreated') attaches the same load and framenavigated listeners to every new page.
  • WebDriver: subscribes to the BiDi events browsingContext.load, historyUpdated and contextCreated once per session, and filters out iframe contexts. Without BiDi nothing is collected, and a debug message says so.
  • Fragments are dropped, and non-http(s) URLs are skipped.
  • run-workers: each worker writes its URLs to a temporary file, and the main process merges them into one sitemap.
  • Pages visited in a Before hook on a freshly started browser are recorded only from the first test onward.

Options: outputName (default sitemap.xml), output (directory), stripQuery (default false).

Testing

  • test/unit/plugin/sitemap_test.js: 8 tests covering dedup, SPA routes and iframe filtering, Puppeteer tabs opened later, Playwright contexts created later, WebDriver BiDi events, stripQuery, the worker merge, and the empty run.
  • Playwright session_test.js: pages opened only inside session() contexts are recorded.
  • Ran the Playwright acceptance within tests locally, both in a single process and with run-workers 2. Both runs passed and wrote the same 7-page sitemap.
  • Ran the Puppeteer acceptance within tests: same sitemap. One @Playwright-only test fails both with and without the plugin.
  • WebDriver was only tested with mocked BiDi events. No Selenium was available locally.

🤖 Generated with Claude Code

DavertMik and others added 2 commits October 9, 2026 22:49
Records every top-level page visited during a run and writes it as a
sitemap XML file. Pages are collected from browser navigation events
(Playwright/Puppeteer framenavigated, WebDriver BiDi browsingContext
events), so no extra browser calls are added to test steps. Results from
run-workers are merged into a single sitemap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Listen to browser context/page creation (Playwright 'context'/'page',
Puppeteer 'targetcreated') and record URLs on page 'load' plus main-frame
'framenavigated' for pushState routes, instead of checking the page on
every step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant