feat: add elementIndex step option for targeting specific elements#5499
Open
feat: add elementIndex step option for targeting specific elements#5499
Conversation
When multiple elements match a locator, users can now specify which one
to interact with using step.opts({ elementIndex }). Supports positive
(1-based), negative (-1 = last), and 'first'/'last' aliases. Silently
ignored when only one element matches. Overrides strict mode when set.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add StepOptions typedef with elementIndex and ignoreCase in JSDoc. Add declare module for 'codeceptjs/steps' for IDE autocompletion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
toAbsoluteXPath() now returns //html/... instead of /html/... to match standard absolute XPath notation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
instanceof fails when StepConfig is loaded from different module paths (e.g., symlinked packages). Add __isStepConfig marker and static isStepConfig() method for reliable detection across module boundaries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Enable strict mode on individual steps without changing helper config:
step.opts({ exact: true }) // Playwright-compatible naming
step.opts({ strictMode: true }) // alias
Throws MultipleElementsFound when multiple elements match, even with
strict: false in helper config.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When helper has strict: true, step.opts({ exact: false }) overrides it
for that step, allowing multiple element matches without error.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
elementIndexstep option to select a specific element when multiple match a locator-1= last), and'first'/'last'aliaseselementIndexis silently ignoredstrict: truemode when set (user explicitly chose which element)Test plan
🤖 Generated with Claude Code