PatrolFinder is Patrol’s custom finder that wraps Flutter’s Finder with enhanced capabilities like automatic waiting, scrolling, and chainable syntax.
Creating Finders
Using the $ Syntax
The primary way to create finders is through the$() method on PatrolIntegrationTester:
Chaining Finders
You can chain finders to locate nested widgets:Core Methods
Interaction Methods
Waits for the widget to be visible and taps it.Parameters:
settlePolicy- How to pump frames after actionvisibleTimeout- Max time to wait for visibilitysettleTimeout- Timeout for settlingalignment- Where to tap (default: center)
Waits for visibility and performs a long press.
Waits for the text field to be visible and enters text.
Waiting Methods
Waits until the finder locates at least one visible widget.Parameters:
timeout- Max time to waitalignment- Point to check for visibility
Waits until the widget exists (not necessarily visible).
Scrolling Methods
Scrolls until this widget becomes visible.Parameters:
view- The scrollable widgetstep- Distance to scroll per iterationscrollDirection- Direction to scrollmaxScrolls- Maximum scroll attempts
Refinement Methods
Returns the widget at the specified index when multiple matches exist.
Returns the first widget found.
Returns the last widget found.
Finds a descendant widget. Chain finders together.
Finds an ancestor widget containing the specified descendant.
Filters widgets using a predicate function.
Returns only widgets that are hit-testable at the specified alignment.
Property Getters
Returns the text content if the widget is a
Text or RichText.Returns
true if the finder locates at least one widget.Returns
true if the finder locates at least one visible widget.Checks visibility at Alignment.center.Returns
true if the widget is visible at the specified alignment.Usage Examples
Basic Widget Finding
Chaining and Nesting
Handling Multiple Matches
Using Predicates
Scrolling
Conditional Logic
Getting Text Content
Chained Actions
createFinder() Function
The underlying function that maps types to Flutter finders:Type→find.byType()Key→find.byKey()Symbol→find.byKey(Key(symbol.name))String→find.text()Pattern→find.textContaining()IconData→find.byIcon()PatrolFinder→ Returns its underlying finderFinder→ Returns itselfWidget→find.byWidget()
See Also
- PatrolIntegrationTester - The tester that creates finders
- patrolTest() - Test function providing the tester