Skip to content

Fix/wait for at#3062

Merged
dworik merged 15 commits into
masterfrom
fix/wait-for-at
May 15, 2026
Merged

Fix/wait for at#3062
dworik merged 15 commits into
masterfrom
fix/wait-for-at

Conversation

@dworik
Copy link
Copy Markdown
Contributor

@dworik dworik commented May 12, 2026

Fixes issue #1938

Problem

first, last, and at() delegated directly to Flutter finders, which throw immediately for empty results (StateError/RangeError). That prevented Patrol’s normal waiting behavior in tap()/waitUntilVisible() from kicking in when a widget appeared later.

Fix

Replaced those selectors with a Patrol wrapper that returns an empty result instead of throwing when the selected element is not available yet. This lets waitUntilVisible() keep retrying until the widget appears or the regular timeout is reached.

Test plan

  • dart analyze in packages/patrol_finders clean
  • flutter test in packages/patrol_finders/test - 127/127 passed, including 7 new tests covering:
    • negative numbers
    • widgets appearing after delay
    • non-existing widgets
  • patrol test in dev/e2e_app/patrol_test/at_finder_test.dart - successfully waits for a second widget to appear without throwing.
at._demo.mov

CI

  • test android emulator webview... expected to fail

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the standard finder.at(index) with a custom _PatrolIndexFinder implementation, enabling finders to wait for elements at specific indices to appear. Test cases have been updated to reflect that out-of-bounds indices now result in no widgets found rather than throwing an error. A critical bug was identified in the new filter logic where negative indices would cause a crash; it is recommended to handle these by returning early to ensure consistency with positive out-of-range indices.

Comment thread packages/patrol_finders/lib/src/custom_finders/patrol_finder.dart Outdated
@dworik dworik marked this pull request as ready for review May 14, 2026 07:11
Copy link
Copy Markdown
Collaborator

@pdenert pdenert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add video of the demo run of this tests

Comment thread packages/patrol_finders/lib/src/custom_finders/patrol_finder.dart Outdated
Comment thread packages/patrol_finders/lib/src/custom_finders/patrol_finder.dart
Comment thread packages/patrol_finders/test/patrol_finder_test.dart
Comment thread dev/e2e_app/patrol_test/at_finder_test.dart Outdated
Comment thread dev/e2e_app/pubspec.yaml Outdated
@dworik dworik merged commit 4711bab into master May 15, 2026
12 of 20 checks passed
@dworik dworik deleted the fix/wait-for-at branch May 15, 2026 12:31
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.

2 participants