Skip to content

Conversation

@omachala
Copy link
Owner

Summary

Switch from custom querySelector implementation to Playwright's native page.locator() API, enabling full Playwright selector format support.

Breaking Change

  • Shadow DOM piercing syntax standardized to >> (Playwright standard)
  • Legacy >>> syntax still works (auto-converted to >>)

New Selector Formats Supported

Now supports all Playwright selector types:

Format Example Use Case
CSS .button, #header Default, most common
Shadow DOM my-component >> .inner Web components
XPath xpath=//button[@id="submit"] Complex DOM traversal
Text text=Submit Select by visible text
Role role=button[name="OK"] ARIA-based selection
Chained .modal >> role=button[name="Close"] Combine selectors

Changes

  • elementFinder.ts: Use page.locator() instead of custom evaluateHandle
  • browserFunctions.ts: Support both >>> and >> syntax
  • editor/selector.ts: Support both syntaxes in visual picker
  • Added normalizeSelector() function with tests
  • Updated docs with new selector format reference

Test plan

  • All 407 unit tests pass
  • All 77 editor tests pass
  • Manual test with shadow DOM components
  • Manual test with XPath and text selectors

@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2026

🦋 Changeset detected

Latest commit: d8c1d91

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Ondrej Machala added 14 commits January 28, 2026 16:36
BREAKING CHANGE: Shadow DOM piercing syntax changes from `>>>` to `>>` (legacy `>>>` still works)

- Use page.locator() instead of custom querySelector for element capture
- Support all Playwright selector formats: CSS, XPath, text, role
- Shadow DOM: use `>>` for chaining (Playwright standard)
- Backward compatible: `>>>` auto-converts to `>>`
- Add normalizeSelector() for syntax conversion
- Update browserFunctions and editor to support both syntaxes
- Add elementFinder tests
- Document new selector formats in screenshot-reference.md
- Add sync.test.ts with 11 tests for sync() function
- Fix gap: throw error when explicit config path doesn't exist
- Previously silently returned empty result for missing config
- Tests cover: empty config, filter handling, options validation
- Add 6 tests for syncHandler in tools.test.ts
- Tests cover: error handling, empty config, filter passthrough,
  result structure, session key from env, explicit session key priority
- Test that empty jobs array returns empty results without launching browsers
- Note: Full error handling tests for batch failures would require
  browser mocking which is complex
- Add tests for whitespace trimming, double space collapsing
- Test empty string, single > (CSS child combinator), mixed >>> and >>
- Document that findElement() is tested via CLI integration tests
- Add test that verifies form is filled correctly by actions
- Test captures form after type, select_option, and evaluate actions
- Compares result to baseline (runs on CI only for font consistency)
- Add screenshotPath tests: very long names, unicode, empty, special chars
- Add schema tests: URLs with special chars, IDN domains, fragments, ports
- Add performance test: config with 100 screenshots
- Test empty session file returns null
- Test truncated/corrupted file returns null
- Test random binary garbage returns null
- All corrupted files handled gracefully without throwing
- Test class names with special characters (: and [)
- Test SVG elements inside shadow DOM
- Test deeply nested shadow DOM (host >> host >> element)
- Changed from Promise.all to Promise.allSettled in captureParallel
- If one worker's browser fails, other workers' results are still collected
- Prevents losing all results when a single batch encounters an error
- Update selector schema description to mention Playwright selector formats
- Regenerate docs from updated schema
- Increase test timeout for 'fails gracefully with invalid selector' from 60s to 90s
  (test takes ~40s locally, CI is slower)
Add NOSONAR comments to test code that uses:
- Math.random() for generating random test data (not crypto)
- /tmp/test as mock output directory (not production code)
@omachala omachala force-pushed the feat/playwright-locators branch from 99560e0 to d8c1d91 Compare January 28, 2026 16:36
@sonarqubecloud
Copy link

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.

2 participants