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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Looping Issue

(0) ShareShare
ReportReport
Posted on by

I have built a power automate desktop flow to open a particular website. On the homepage of this website there are at least 113 rows of information. Each row has a hyperlink called "Details". I would like to click each "details" hyperlink and be routed to the linked site and extract the data into Excel. I have built the flow to click the correct links, however it is looping in circles on the first row of "details". I need it to advance to the next "details" hyperlink on the next row and repeat the process until it has extracted data from all of the "details" hyperlinks. I think the issue may be the way the looping is set up. I also tried a "for each" loop and had no luck. Does anyone have any advice on what could be causing the flow to go in circles and not advance to the next row? Please see attached flow for details.

I have the same question (0)
  • eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    Can you show the Selectors of UI element that your Click UI element is using? There should be Ordinal that is 0. That indicates it will always click first row. So if you change it to 1 it should click second row. 

    Example:

    eetuRobo_1-1711647344855.png

    So you need to put your loop index variable there to click correct row

    Then how you make that dynamically choose next row each time is that you put variable in the Ordinal. Also click Text editor enabled and make sure the variable is in there (bug in PAD that variables don't usually work in UI element when text editor is not enabled). 
    So create row variable that starts from 0 and increase it every loop by one and use that in Ordinal.

    eetuRobo_2-1711647507769.png

     

     

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @mmd23 

     

    I suggest utilizing a "for each" loop instead of a standard loop. Additionally, I noticed that you are interacting with the browser using Windows automation actions (such as "Click UI element on window"), which may not be the most appropriate approach[You can use "Click link on web page" or "Go to web page"].

     

    Therefore, I've created a similar flow tailored to your use case. Please review it and see if it resolves your issue.

    Deenuji_0-1711647301411.png

     

    Code[Just for your reference]:

     

    WebAutomation.LaunchChrome.LaunchChrome Url: $'''https://afd.calpoly.edu/web/sample-tables''' WindowState: WebAutomation.BrowserWindowState.Normal ClearCache: False ClearCookies: False WaitForPageToLoadTimeout: 60 Timeout: 60 PiPUserDataFolderMode: WebAutomation.PiPUserDataFolderModeEnum.AutomaticProfile BrowserInstance=> Browser
    WebAutomation.ExtractData.ExtractHtmlTable BrowserInstance: Browser Control: $'''html > body > div:eq(1) > div:eq(0) > table:eq(1)''' ExtractionParameters: {[$'''Name''', $'''Telephone''', $'''Email''', $'''Office'''], [$'''''', $'''''', $'''''', $''''''] } PostProcessData: False TimeoutInSeconds: 60 ExtractedData=> DataFromWebPage
    LOOP FOREACH CurrentItem IN DataFromWebPage
     WebAutomation.Click.Click BrowserInstance: Browser Control: appmask['Web Page \'https://afd.calpoly.edu/web/sample-tables\'']['Anchor \'Lorem ipsum dolor\''] ClickType: WebAutomation.ClickType.LeftClick MouseClick: True WaitForPageToLoadTimeout: 60 MousePositionRelativeToElement: WebAutomation.RectangleEdgePoint.MiddleCenter OffsetX: 0 OffsetY: 0
     WebAutomation.GoToWebPage.GoToWebPage BrowserInstance: Browser Url: CurrentItem WaitForPageToLoadTimeout: 60
     WebAutomation.ExtractData.ExtractHtmlTableInExcel BrowserInstance: Browser Control: $'''html > body > div:eq(1) > div:eq(0) > table:eq(4)''' ExtractionParameters: {[$'''Day''', $'''Time''', $'''Location'''], [$'''''', $'''''', $''''''] } PostProcessData: False TimeoutInSeconds: 60 ExcelInstance=> ExcelInstance
     WebAutomation.GoToWebPage.NavigateBack BrowserInstance: Browser WaitForPageToLoadTimeout: 60
    END
    Excel.SaveExcel.Save Instance: ExcelInstance

     

     

    How to copy/paste above suggested code into your power automate?

    Deenuji_1-1711647670587.gif

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀. If you'd like to appreciate me, please write a LinkedIn recommendation 🙏

  • VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at

    Hi @mmd23 ,

     

    As per my understanding I don't think you need to click on details button. You can directly extract the Href Link (Hyperlink) and you can navigate to that webpage directly.

    Please find the attached solution. I have tried on different website.

     

    VishnuReddy1997_0-1711690177920.pngVishnuReddy1997_1-1711690205434.png

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    As others have suggested, in order to be able to loop through items and click on row items, you need to modify the selector involved. Here are some useful resources for building custom selectors: https://learn.microsoft.com/en-us/power-automate/desktop-flows/build-custom-selectors?wt.mc_id=MVP_307182  as well as this video: https://www.youtube.com/watch?v=2PcyBa22Jj8&ab_channel=Thomas%22Shaky%22Petersen

     

    But what I would recommend instead is to try and extract the URL behind the hyperlink instead, as you extract your data. And then simply use Go to web page to navigate to that URL within your loop, instead of trying to click the element. This is usually much more stable and robust, and does not require capturing and modifying UI elements.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard