Fix negative nth selector boundary - #240
Merged
Merged
Conversation
Vinyzu
requested a deployment
to
pr-artifact-build
September 2, 2026 20:52 — with
GitHub Actions
Waiting
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is a minimal, well-scoped boundary fix that directly addresses the reported off-by-one error without altering unrelated logic.
Pull request overview
Fixes an off-by-one boundary condition in Patchright’s nth() locator handling so negative indices like .last / nth(-1) (and more generally nth(-N)) resolve correctly when the matched element count equals N, aligning .count() behavior with other locator operations.
Changes:
- Adjusted the negative
nthrange check in_customFindElementsByParsedto treat-lengthas a valid index (instead of incorrectly out-of-range). - Preserves existing behavior for positive indices and truly out-of-range negative indices.
File summaries
| File | Description |
|---|---|
| driver_patches/framesPatch.ts | Fixes negative nth() boundary check so nth(-length) is considered valid, preventing .count() from returning 0 for .last on a single match. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #239