web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to iterate through...
Power Automate
Suggested Answer

How to iterate through a web table using a dynamic selector (Ordinal/eq) in Power Automate Desktop?

(1) ShareShare
ReportReport
Posted on by 106
Hi everyone,
I am trying to automate a process in a web application, where I need to click each row in a table to download "Delivery Logs" one by one.

What I want to achieve:
Click the "Actions" button for each row in the table.Navigate to the detail page and download the CSV.Go back to the main table and move to the next row.
 
Current Setup:
I am using a For each loop with a counter variable %LoopCounter%.
My selector for the row is: div[id*="grid"] > div:eq(%LoopCounter%)
After downloading, I use "Go to web page (Back)" and a "Wait" of 10 seconds.
I increment the %LoopCounter% by 1 at the end of the loop.
 
The Problem: The flow does not work, it either fails to find the next element or clicks the wrong place. It seems the "Ordinal" or "eq" index is not correctly pointing to the next row after the page refreshes.
Error Message: "Could not find UI element" for div > div:eq(0) (or the current index).

Could you please help me to solve this problem, step by step guide is really appreciated.
Thank you in advance!
I have the same question (0)
  • Suggested answer
    Valantis Profile Picture
    3,258 on at
     
    The :eq() syntax is actually valid in PAD selectors Microsoft's own docs use exactly this pattern with %LoopIndex% to click rows in a list. So the syntax is not the core issue.
     
    The real problem is that after navigating away and coming back, the browser reloads the page and the DOM is rebuilt. PAD's cached UI element reference from before navigation is stale, so it fails to find the element.
     
    The fix is to re-capture the element on every iteration rather than relying on a cached reference. Here is the correct structure:
    1. Set LoopCounter = 0
    2. Loop (start: 0, end: total rows - 1)
       a. Wait for the table to be present (use "Wait for UI element" on the table container)
       b. Click web link / Click UI element using the dynamic selector each time fresh — do NOT rely on a pre-captured element that was stored before the loop started
       c. On the detail page: download the CSV
       d. Go back
       e. Wait (your 10 seconds is fine, but "Wait for UI element" is more reliable than a fixed wait)
       f. Increment LoopCounter
    3. End Loop
     
    The key change: make sure the Click action uses the selector with %LoopCounter% directly in the selector text at the time of clicking, not a UI element reference captured before the loop. In PAD, edit the selector in Text mode to something like:
    div[id*="grid"] > div:eq(%LoopCounter%)
    And make sure %LoopCounter% starts at 0 if the first row is :eq(0), or 1 if the first data row is :eq(1) (header rows may offset the index).
     
    Also check: if the table has a header row, :eq(0) is the header. Your data rows likely start at :eq(1). Try manually testing the selector in the PAD selector builder with a fixed value first to confirm the correct starting index before running the loop.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Suggested answer
    eetuRobo Profile Picture
    4,518 Super User 2026 Season 1 on at
    If @Valantis suggestion was not the solution for you issues then here is a possible solution:

    One likely reason could have to do with long lasting bug on PAD that forgets variable in ordinal if you don't put it in "Text editor" -mode in your selectors editor. 

    So if you save a variable in normal editor (text editor toggled off as in the picture) then it does not actually save it in the selector. You can see it in the image I have %LoopCounter% on the tr elements Ordinal attribute but it does not update to the Preview Selector in the bottom.

    And if I press Save and reopen that selector then the Ordinal value is empty so the %LoopCounter% is not even on the top part anymore.

    Switch to Text editor -mode and put the variable in side the eq() yourself and then press Save. Then it should have saved it.
    (never toggle the Text editor off on that selector and save it or it will forget the variable again)


    If thats not provide a solution then have you tested the selectors with the Test -button?


    Does that find the elements with different ordinals? What if you give it hard coded ordinal that is something else than 0? Does the selector find the correct row? With table make sure you have the %LoopCounter% in the correct ordinal so that its for the row and not for the column of the table.

    Can you show screenshot of your selector?
  • CU10030357-0 Profile Picture
    106 on at
     
    Thank you for the advice! I am already using the "Text editor" mode to ensure the variable is saved correctly.
    Here is the screenshot of my current selector: I attached a photo.
    Current Issue: > When I use %LoopCounter% = 1, it clicks a different part of the page (not the first row of the table). It seems PAD is counting elements outside of the target table.
    How can I restrict the selector to only count rows within the specific data grid?
    IMG_loopcounter.png
  • Suggested answer
    eetuRobo Profile Picture
    4,518 Super User 2026 Season 1 on at
    Your selector might be bit too loose/vague for it to find the correct element. So maybe the first div with "gridcell" is not just  the table element but it has other divs inside it and thats why the second div finds different results than just the rows when your LoopCounter increase. Can you recapture the element and add more specificity to it?
    Now your selector finds the grid cell that contains "gridcell" in role attribute and then picks the element inside that dive with the position given by the LoopCounter.

    So it could be that the "div" element that has the %LoopCounter% not the table row. Since you said it works when your LoopCounter is 0 then maybe
     div[role="gridcell"] div:eq(0) = the table element
    and then div[role="gridcell"] div:eq(1) would not even be the table element anymore. So maybe in div[role="gridcell"] > div:eq(0) > div:eq(%LoopCounter%) or better yet if the table is actually table element then it should find it with something like this: div[role="gridcell"] > table[Id="Your Table Id Here"] > tbody > tr:eq(%LoopCounter%)
    That would select the whole row of the table. If you want also specify column for example first column then add to the end: > td:eq(0)


    If the site is public and you are willing to share it then share it here so we can figure out a good selector syntax for it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 600

#2
Valantis Profile Picture

Valantis 453

#3
11manish Profile Picture

11manish 356

Last 30 days Overall leaderboard