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 Platform Community / Forums / Power Automate / Press a button dynamic...
Power Automate
Answered

Press a button dynamically

(1) ShareShare
ReportReport
Posted on by 32
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>
I have the same question (0)
  • Suggested answer
    eetuRobo Profile Picture
    4,220 Super User 2025 Season 2 on at
    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.
  • T24k Profile Picture
    32 on at
    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!
  • Verified answer
    eetuRobo Profile Picture
    4,220 Super User 2025 Season 2 on at
    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

     

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 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard