How to break the loop?

Im using for each uielement activity to click on the row and enabled extract multiple pages and indicated the arrow icon at the buttom of the table. After clicking the arrow icon fro 2nd page,all row are clicked correctly, after clicking the last row, the loop runs again from 1st row of the 2nd page. but loop need to be stopped once it reaches the last of the 2nd page

Hi @Prabhakaran_Elango

Try the below steps

  1. After clicking the Next (→) page arrow, use Element Exists on the same arrow.
  2. If Element Exists = False (or arrow is disabled / not clickable) → Exit For Each (or Break).
  3. Else → continue to next page.

Logic:

  • Page 1 → process rows
  • Click Next → Page 2 → process rows
  • Next arrow not available → Stop loop

Regards,
Gokul

Hi @Prabhakaran_Elango ,

Another approach would be to use the count of ui elements/ rows and put an if condition inside your loop, if the index= count of ui elements/ rows then use the break activity to come out of the loop.

BR,

but I have enabled the scrape multiple page and indicated the next button while indicating the pattern, there is no seperate activity to indicate the next icon. can you pls give me the exact workflow to fix this.

hI @Prabhakaran_Elango

Check the flow

Use Application/Browser
└── While (continue = True)
├── Find Children (Table)
│ → Output: rows (IEnumerable)

├── For Each row in rows
│ └── Click row

├── Check App State / Element Exists
│ ├── Target: Next Page Arrow

│ ├── If Exists
│ │ ├── Click Next Arrow
│ │ ├── Delay 00:00:01
│ │
│ └── Else
│ ├── Assign continue = False
│ └── Break

Regards,
Gokul

Hi @Prabhakaran_Elango

Alternative approach bage count

Use Application/Browser
└── While True
├── Get Text → pageText (“Page 2 of 2”)

├── Assign
│ pageNumbers = pageText.Replace(“Page”,“”).Split(“of”)
│ currentPage = CInt(pageNumbers(0).Trim)
│ totalPages = CInt(pageNumbers(1).Trim)

├── Find Children (rows)
├── For Each row → Click

├── If currentPage = totalPages
│ └── Break

└── Click Next Arrow

Regards,
Gokul

Hi @Prabhakaran_Elango

  1. Use Application/Browser (indicate page)
  2. While True
  • For Each UI Element
    Target: table container
    Filter: <webctrl tag='TR' />
    Body: Click (Target: CurrentElement)
  • Check App State (Target: Next/arrow)
  • If Exists = True and IsEnabled = True
    Click (Next/arrow)
    Use Application/Browser → Wait for page to load Else
    Break

notes:
don’t use Extract multiple pages; control paging with Check App State + Click.
add small Delay After in Click if needed (200–300 ms).

Happy Automation

@Prabhakaran_Elango

You can use the property limit and give it as max pages and value as 2

Hope this helps

cheers

Hi @Prabhakaran_Elango

In for loop you can use break activity where you want to stop the count.

Hope it works !

you can use break and continue to exit loop based on the requirement.

Continue skips the current loop iteration and moves to the next one.
Break exits the loop completely and stops further processing.