Commit aed9f0e
feat: add elementIndex step option for targeting specific elements (#5499)
* feat: add elementIndex step option for targeting specific elements
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>
* feat: add TypeScript types for step options and codeceptjs/steps module
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>
* fix: use absolute XPath with // prefix in MultipleElementsFound error
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>
* docs: rename strict.md to element-selection.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: use duck-typing for StepConfig detection instead of instanceof
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>
* feat: add exact and strictMode step options for per-step strict mode
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>
* feat: exact: false cancels strict mode per-step
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>
* fix: role locators now use getByRole() when wrapped in Locator object
handleRoleLocator used isRoleLocatorObject() which rejected Locator-wrapped
role objects (checking !locator.type). This caused findClickable to fall
through to a CSS [role="button"] selector, losing text/exact filters.
Now uses new Locator(locator).isRole() to detect role locators regardless
of whether they arrive as raw objects or Locator instances, ensuring
Playwright's native getByRole() API is always used.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: use Array.from() for WebDriver element collections in selectElement
WebDriver returns element collections that aren't plain arrays, so
.map() may not work correctly. Matches the pattern used in WebDriver's
own assertOnlyOneElement.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: add exact/strictMode per-step options to element selection guide
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: DavertMik <davert@testomat.io>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent b6aed85 commit aed9f0e
File tree
11 files changed
+422
-123
lines changed- docs
- lib
- element
- helper
- extras
- step
- test/helper
- typings
11 files changed
+422
-123
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
| 355 | + | |
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
0 commit comments