Skip to content

feat: Multi-remote element matchers ($() and $$()) - #2230

Merged
dprevost-LMI merged 4 commits into
webdriverio:mainfrom
dprevost-LMI:multi-remote-3-element-matchers
Sep 25, 2026
Merged

dprevost-LMI merged 4 commits into
webdriverio:mainfrom
dprevost-LMI:multi-remote-3-element-matchers

Conversation

@dprevost-LMI

Copy link
Copy Markdown
Collaborator

Part 3/4 of the multi-remote support split from #2172.

  • Multi-remote strict strategy for $() and $$(): each instance is compared on its own elements, with a single expected value, an index-based array, or one value per instance (expect.multiRemote() or plain object shorthand); .not, some() and expect.arrayContaining() apply per instance
  • Re-fetching of multi-remote $$() between retries, reliable with WDIO_ENABLE_MULTI_REMOTE_ELEMENT_ARRAY, best effort without it
  • toBe* and string matchers (text, attribute, HTML, class, id, href, value, computed label/role) support multi-remote elements; toHaveText requires the strict strategy flag
  • Failure messages per instance, e.g. multi-remote<chrome, firefox>.$(h1)
  • toHaveSize, toHaveStyle and toHaveElementProperty keep a plain object as a literal
  • Types, type tests, docs and multi-remote playground specs

Number, size and object matchers and toBeElementsArrayOfSize come in part 4.

Part 3/4 of the multi-remote support split from webdriverio#2172.

- Multi-remote strict strategy for `$()` and `$$()`: each instance is compared on its own
  elements, with a single expected value, an index-based array, or one value per instance
  (`expect.multiRemote()` or plain object shorthand); `.not`, `some()` and
  `expect.arrayContaining()` apply per instance
- Re-fetching of multi-remote `$$()` between retries, reliable with
  `WDIO_ENABLE_MULTI_REMOTE_ELEMENT_ARRAY`, best effort without it
- `toBe*` and string matchers (text, attribute, HTML, class, id, href, value, computed
  label/role) support multi-remote elements; `toHaveText` requires the strict strategy flag
- Failure messages per instance, e.g. multi-remote<chrome, firefox>.$(`h1`)
- `toHaveSize`, `toHaveStyle` and `toHaveElementProperty` keep a plain object as a literal
- Types, type tests, docs and multi-remote playground specs

Number, size and object matchers and `toBeElementsArrayOfSize` come in part 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dprevost-LMI
dprevost-LMI marked this pull request as ready for review September 25, 2026 19:42
@greptile-apps

greptile-apps Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Extends element matchers to support multi-remote element queries.

The PR appears safe to merge based on this review; no outstanding finding or new actionable issue was established.

Findings

  1. P1 Active test calls stale element ▶

Summary

This PR adds strict, per-instance assertions for multi-remote $() and $$() elements, including expected-value handling, array re-fetching, types, tests, and documentation. Since the previous review, it also corrects toHaveValue shorthand handling, rejects multi-remote elements under the legacy text strategy after awaiting them, and removes the direct stale-element call from the playground test.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Multi-remote element assertion"] --> B["Resolve $() or $$() subject"]
  B --> C["Group elements by browser instance"]
  C --> D["Compare against shared or per-instance expectations"]
  D --> E["Retry and re-fetch $$() when available"]
  E --> F["Report per-instance result"]
Loading

Reviews (2) · Last reviewed commit: "test: remove leftover debug log from mul..."

Comment thread src/util/executeCommand.ts Outdated
Comment thread src/matchers/element/toHaveElementProperty.ts Outdated
Comment thread playgrounds/multi-remote-mocha/test/specs/wdio-matchers.test.ts Outdated
dprevost-LMI and others added 3 commits September 25, 2026 16:43
…y, also non-awaited and with .not

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
toHaveValue delegates to toHaveElementProperty, which keeps a plain object as a literal
property value. A value is a string, so for toHaveValue a plain object is the per-instance
shorthand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dprevost-LMI

Copy link
Copy Markdown
Collaborator Author

@greptileai, anything left to do/fix?

@greptile-apps

greptile-apps Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Nothing else from my review. The three issues previously identified are addressed and their threads are resolved/outdated: legacy .not.toHaveText() handling, toHaveValue per-instance shorthand, and the playground’s stale-element/debug code. The PR is currently mergeable and I don’t see another actionable correctness issue in this part; the remaining number/size/object matcher work is already scoped to Part 4.

@dprevost-LMI
dprevost-LMI merged commit f6d597c into webdriverio:main Sep 25, 2026
10 checks passed
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.

1 participant