-
Notifications
You must be signed in to change notification settings - Fork 0
Search.Any
David O'Donoghue edited this page Jan 28, 2026
·
2 revisions
Find elements by matching against name, text, sprite, or path simultaneously.
using static ODDGames.UIAutomation.ActionExecutor;
Search.Any(string pattern)
// Or using the static helper from ActionExecutor:
Any(string pattern)| Parameter | Type | Description |
|---|---|---|
pattern |
string | Pattern to match (supports * wildcards and ` |
Any searches across multiple element properties:
| Property | Description |
|---|---|
| GameObject name | The name in the hierarchy |
| Text content | TMP_Text or Text component content |
| Sprite name | Image component sprite name |
| Hierarchy path | Full path like "Canvas/Panel/Button" |
If the pattern matches any of these, the element is included.
// Find anything containing "Settings"
await Click(Any("*Settings*"));
// Matches: GameObject named "SettingsButton", text "Settings", sprite "settings_icon", path "Menu/Settings"
// Find anything with "play"
await Click(Any("*play*"));
// Matches: "PlayButton", "Play", "play_icon", "MainMenu/Play"// Find anything starting with "btn_"
await Click(Any("btn_*"));
// Find anything ending with "Panel"
await Wait(Any("*Panel"));
// Find anything containing "user"
await Click(Any("*user*"));// Find settings by any common identifier
await Click(Any("*settings*|*options*|*preferences*"));
// Find close/cancel actions
await Click(Any("*close*|*cancel*|*back*|X"));| Scenario | Recommendation |
|---|---|
| Not sure how element is identified | Use Any()
|
| Element has consistent naming | Use Name()
|
| Element has visible text | Use Text()
|
| Element has distinctive icon | Use Sprite()
|
| Need precise matching | Use specific method |
Any is useful for:
- Exploratory testing when you don't know the exact identifiers
- Flexible matching across different UI implementations
- Finding elements that might be named differently across scenes
Combine with other conditions for more precise matching:
// Find anything "settings" that's a button
await Click(Any("*settings*").Type<Button>());
// Find anything "close" in the top-right
await Click(Any("*close*|X").InRegion(ScreenRegion.TopRight));
// Find anything "submit" that's interactable
await Click(Any("*submit*").Interactable().First());Any searches more properties than specific methods, so it may be slightly slower. For performance-critical tests or when you know the exact identifier type, prefer:
// More efficient if you know it's a text element
await Click(Text("Settings"));
// More efficient if you know it's named
await Click(Name("SettingsButton"));// Find any confirmation button
await Click(Any("*ok*|*confirm*|*yes*|*accept*|*submit*"));
// Find any navigation element
await Click(Any("*back*|*home*|*menu*|*nav*"));
// Find any error/warning indicator
await Wait(Any("*error*|*warning*|*alert*"));// Works whether it's a "SettingsButton", "Settings" text, or "settings" sprite
await Click(Any("*settings*").First());
// Works across different UI implementations
await Click(Any("*play*|*start*|*begin*").First());// Find all elements related to "user"
var userElements = await FindAll<RectTransform>(Any("*user*"));
foreach (var el in userElements)
{
Debug.Log($"Found: {el.name}");
}Basic Filters
Proximity
Hierarchy
Spatial
Ordering
Modifiers
Combining
Reflection
- Click Actions
- Text Input
- Drag Actions
- Gesture Input
- Wait and Find
- Assertions
- GameObject Manipulation