Example Code

agent.act('Wait for the Site to load, then Click on the third Chevron Icon from the left, below text "Payment Due Date"')

What This Does

1. Waits for UI to load

Before doing anything, the test waits for one second to make sure the UI is rendered and stable.

agent.act('Wait for the site to load,...')

2. Finds all matching elements

We search the screen for all elements that match the given reference image:

agent.act('...Click on the third Chevron Icon...')

This returns a list of matching elements.

3. Sorts elements top to bottom

We sort the found elements by their horizontal position on the screen (xmin):

agent.act('...Icon from the top...')

This ensures the topmost element is at index 0, the second one at index 1, and so on.

4. Clicks on the selected element

We pick the element at the desired index, move the mouse to its center, and click:

agent.act('...Click,...below text "Payment Due Date"')

When to Use This

Use this approach if:

  • You want to interact with repeated elements (e.g., list items, buttons).
  • You need to click a specific one (e.g., the second, third, etc.).
  • The elements look identical or similar, and position is the only differentiator.

Tips

  • Make sure the reference image clearly captures the element.
  • Test with different screen resolutions or zoom settings to ensure consistency.
  • You can adjust the index parameter to click a different element.