You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Users can now query HTML elements by their visible label text. The feature supports multiple labeling mechanisms including for attributes, wrapping label elements, aria-label attributes, and aria-labelledby references. Both single and multiple element queries are supported.
Tests
Added comprehensive test coverage for label-based element queries and edge cases.
This PR introduces label-based element querying to the rapid-test HTML testing library. It adds a new rapid-test.html.label module with get-by-label and get-all-by-label functions, extends utilities for ID lookup and pattern matching, and updates the public API exports to include these new label-based functions alongside existing role-based queries.
Changes
Cohort / File(s)
Summary
New Label Module src/main/rapid_test/html/label.clj
Introduces label-based element query functions supporting four labeling mechanisms: for attribute, wrapping label ancestor, aria-label, and aria-labelledby. Implements get-by-label and get-all-by-label using hiccup zipper traversal.
API Exports src/main/rapid_test/html.clj
Expands re-exports to include label-based query functions (get-by-label, get-all-by-label) from the new rapid-test.html.label module, alongside existing role-based exports.
Adds find-by-id function for ID-based element lookup and text-match? for pattern/string matching; refactors matches-options? to use text-match? for name-based matching logic.
Test Coverage test/main/rapid_test/html_test.clj
Adds get-by-label-test and get-all-by-label-test covering multiple labeling strategies, edge cases, and empty result scenarios.
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~22 minutes
Possibly related PRs
Create first html testing utils #78: Extends the rapid-test.html API with label-based query functions, directly building on the existing namespace structure.
Html testing utils #79: Previously introduced role-based functions and utilities in rapid-test.html; this PR parallels that pattern by adding label-based alternatives.
Poem
🐰 A label-based quest, through hiccup trees we hop,
With aria and for-loops, we'll never miss a stop,
Four ways to find your elements, all bundled up so tight,
By text and ID and ARIA—your tests will shine so bright! ✨
✨ Finishing touches🧪 Generate unit tests (beta)
Create PR with unit tests
Post copyable unit tests in a comment
Commit unit tests in branch add-label-html-helpers
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit
New Features
Tests