Skip to main content

Notifications

Power Automate - Power Automate Desktop
Answered

Press a button dynamically

(1) ShareShare
ReportReport
Posted on by 30
Hello Everyone, My task is to automate file downloads from a website using Power Automate Desktop (PAD). The users require the files to be downloaded in order, starting from the oldest to the newest. The website has multiple pages, as shown in the screenshot. The bot needs to click on the last page button (e.g., 134 in the screenshot), download and delete the files on that page, and then move to the previous page (133). This process should continue until all the pages are processed. I'm unsure how to implement this in PAD and would appreciate your guidance. Thanks in advance! 
 
 
Here is the code when I inspect the button.      <button type="button" aria-label="Go to page 134" aria-current="true" class="page-link" style="z-index: auto;">134</button>
  • Verified answer
    eetuRobo Profile Picture
    eetuRobo 2,574 on at
    Press a button dynamically
    You can store the last page dynamically. When you navigate to the page have PAD take the last page number and store it into a variable.

    In this example I use Extract Data from web page -action to get the element that has all the visible page numbers.



    So it will return the pages visible so it will include the last page. By itself it will return:


    But if I use regex in the advanced settings then I can get it to return the last digit before ">". For you it would probably be last digit before "Next". 






    Then use Convert text to number

    So then I have this:


     

    Then use that LastPage variable in a loop. Use Press button on web page to press the last button. But you need to modify the UI element so that it has the variable in it so it will be dynamic. So in my case the last page element had Text value 18 but I changed it to be %LastPage% so it always refers to the LastPage variable.


     
    So the loop will go from top to bottom. LastPage being always the top page number and loop always will decrease by 1 and loop will end when its at page 1

     
  • T24k Profile Picture
    T24k 30 on at
    Press a button dynamically
    Hi @eetuRobo, Thank you so much for your response. To answer your question, when accessing the website, it initially loads files from page 1. For example, to navigate to page 134, I need to manually click the button for that page. After downloading and deleting files using Power Automate Desktop (PAD), the total number of pages decreases, making the last page 133. As files are processed, the total page count continues to decrease.
     
     
    My question is: how can PAD be configured to automatically navigate to the last page, given that the last page number cannot be stored in a variable and changes dynamically? For instance, the first time I run the bot, the last page might be 134. After downloading and deleting some files, the page count changes, so the next time I run the bot, the last page number will be different. How can PAD handle this scenario to ensure it navigates to the previous page after processing files? 
     
    The code below allows me to download files starting from page 1. However, I need to modify it to start downloading from the last page, as the user prefers to process and delete older files first. Any suggestions on how to achieve this would be greatly appreciated. Thank you!
  • Suggested answer
    eetuRobo Profile Picture
    eetuRobo 2,574 on at
    Press a button dynamically
    Some questions regarding the workings of the page:
    -Can you get to the last page easily when you first go to that website? I assume when you first go to the website it has you on page 1. Does it show the last page always or does it have "Last page" button?
    -If you delete the files from the page 134 does it then disappear and the last page would be 133?
     
    I would store the last page number into a variable %PageNumber% (with Details of element on web page) and use that in the element like so:
    <button type="button" aria-label="Go to page %PageNumber%" aria-current="true" class="page-link" style="z-index: auto;">%PageNumber%</button>

    Then when the bot has downloaded and deleted the files on that page (134) decrease 1 from the %PageNumber% so that it would be 133 and press the go to page button and repeat the process.

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

End of Year Newsletter…

End of Year Community Newsletter…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #11 New Opportunities…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,609

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,420

Leaderboard