cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

How to click every instance of a UI element on a webpage

I have a website with 6000+ search results and for each result, there is a PDF that I need to download and a button to generate that PDF (see screenshot below). Clicking that button results in the file downloading with the name that it needs to my download folder so it seems like it should  be a very simple automation - open the URL (which displays the search results), click every Generate PDF button on the page (the search results on each page can be set to up to 200), click Next Page and go through the process again until Next page is no longer an option. Seems simple, but I am new to Power Automate Desktop. I have the necessary licenses, but could someone point me in the right direction? 
2021-08-10_18-18-44.png

18 REPLIES 18

I am not familiar with clicking on redundant UI selectors; I know there is a way to say, click on 1st UI = Generate, click on next UI = Generate, but I don't know enough about it.

 

If I were building this, I would assume this site accepts Send Keys {Tab} to use as a selector, and then I could go into a loop:

Loop using LoopIndex 200 to 6000 increment of 200

Loop using LoopIndex 1 to 200 increment of 1

If LoopIndex = 1

Send Keys {Tab} 'as many tabs as you need to get to the first Generate

End If

If LoopIndex >1

Send Keys {Tab}{Tab}{Tab}{Tab}{Tab} 'looks like 5 tabs to get to your next Generate

End If

Send Keys {Return}

Whatever other commands you need to save your file and get back to the website screen

If LoopIndex = 200

Send Keys {Tab} 'tabs to get the next page icon

Send Keys {Return}

End If

End Loop

End Loop

 

Best of Luck.

----
If my post has answered your question, please thumbs up and mark this post as a solution.

I also offer paid consulting services at www.peakdigitran.com/appointments and you can find me on LinkedIn at https://www.linkedin.com/in/michael-annis-80903/,

Thanks so much for your quick response! That was just a part of the page so there are a lot of tabs to get to each button and although the examples I showed always have 5 tabs to get to the next Generate within that column of the table, that isn't always the case. Sometimes it might only be 2 and sometimes it could be more than 5. I think there are enough differences where I couldn't do any solutions based on tab counts and would need to do it based on the buttons. 

I updated the title for more clarity. 

Can you share a snippet of the source code highlighting the selectors for at least 2 of the download links?

----
If my post has answered your question, please thumbs up and mark this post as a solution.

I also offer paid consulting services at www.peakdigitran.com/appointments and you can find me on LinkedIn at https://www.linkedin.com/in/michael-annis-80903/,
Anonymous
Not applicable

Sure. I'll add screenshots with context and the source code for those elements.

 

1)

2021-08-11_10-41-32.png

<button _ngcontent-c1="" class="generate btn btn-link btn-sm" mattooltip="This will generate a single PDF for all files listed for this row" mattooltipclass="help_tip" mattooltipposition="above" aria-describedby="cdk-describedby-message-4" cdk-describedby-host="" style="touch-action: none; user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><svg _ngcontent-c1="" fill="rgb(33,150,243)" height="80%" role="img" viewBox="0 0 48 48" width="30%" xmlns="http://www.w3.org/2000/svg"><title _ngcontent-c1="">Generate PDF icon</title><path _ngcontent-c1="" d="M0 0h48v48H0z" fill="none"></path><path _ngcontent-c1="" d="M40 4H16c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h24c2.21 0 4-1.79 4-4V8c0-2.21-1.79-4-4-4zM23 19c0 1.66-1.34 3-3 3h-2v4h-3V14h5c1.66 0 3 1.34 3 3v2zm10 4c0 1.66-1.34 3-3 3h-5V14h5c1.66 0 3 1.34 3 3v6zm8-6h-3v2h3v3h-3v4h-3V14h6v3zm-23 2h2v-2h-2v2zM8 12H4v28c0 2.21 1.79 4 4 4h28v-4H8V12zm20 11h2v-6h-2v6z" fill="rgb(33,150,243)"></path></svg> Generate PDF </button>

 

2)

2021-08-11_10-42-10.png

<button _ngcontent-c1="" class="generate btn btn-link btn-sm" mattooltip="This will generate a single PDF for all files listed for this row" mattooltipclass="help_tip" mattooltipposition="above" aria-describedby="cdk-describedby-message-4" cdk-describedby-host="" style="touch-action: none; user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><svg _ngcontent-c1="" fill="rgb(33,150,243)" height="80%" role="img" viewBox="0 0 48 48" width="30%" xmlns="http://www.w3.org/2000/svg"><title _ngcontent-c1="">Generate PDF icon</title><path _ngcontent-c1="" d="M0 0h48v48H0z" fill="none"></path><path _ngcontent-c1="" d="M40 4H16c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h24c2.21 0 4-1.79 4-4V8c0-2.21-1.79-4-4-4zM23 19c0 1.66-1.34 3-3 3h-2v4h-3V14h5c1.66 0 3 1.34 3 3v2zm10 4c0 1.66-1.34 3-3 3h-5V14h5c1.66 0 3 1.34 3 3v6zm8-6h-3v2h3v3h-3v4h-3V14h6v3zm-23 2h2v-2h-2v2zM8 12H4v28c0 2.21 1.79 4 4 4h28v-4H8V12zm20 11h2v-6h-2v6z" fill="rgb(33,150,243)"></path></svg> Generate PDF </button>

More like this...on this page, here is reply button #1
<a class="lia-button lia-button-primary" rel="nofollow" id="link_7" href="/t5/forums/replypage/board-id/MPADesktop/message-id/5862"><span>Reply</span></a>

 

Here is reply button #2:
<a class="lia-button lia-button-secondary reply-action-link lia-action-reply iconClass lia-button-slim" id="link_17" href="">Reply</a>

And reply button #3:
<input title="" class="lia-button lia-button-primary lia-button-Submit-action" value="Reply" id="submitContext_3a9954501ec803_0" name="submitContext_0" type="submit">

 

I'm hoping yours is a little cleaner in the selector identifiers...for instance, if all 3 of these said value = Reply, then I believe we can use that to say, click on each iterance of "value = "Reply"".

 

That's my thought process, and I know it is possible, just have to figure it out.

 

----
If my post has answered your question, please thumbs up and mark this post as a solution.

I also offer paid consulting services at www.peakdigitran.com/appointments and you can find me on LinkedIn at https://www.linkedin.com/in/michael-annis-80903/,

2021-08-11_10-41-32.png

2021-08-11_10-42-10.png

Sorry. Every time I tried to copy the source code or insert snippets, it wouldn't show up in the thread. The only way to make it work was to do screenshots.

Anonymous
Not applicable

Check if this works for you: Click on several links on a web page, one after the other | Microsoft Docs

It's from WinAutomation documentation, but logic and actions apply to PAD.

Thanks @Anonymous , this is what I was trying to get at.  I tried to create this on this very page to capture all the reply buttons using attribute value="Reply", but didn't have any luck.  Are you able to?

----
If my post has answered your question, please thumbs up and mark this post as a solution.

I also offer paid consulting services at www.peakdigitran.com/appointments and you can find me on LinkedIn at https://www.linkedin.com/in/michael-annis-80903/,
tkuehara
Solution Specialist
Solution Specialist

Hi @joshlwulf 

 

So, basically, you have a table with lots of rows and a fixed column with the button element in each row (I'm reading from the HTML print screens).

Also, you have the paging requirement. I'll divide the solution in these two major groups:

  1. The rows iteration; meaning the process to click at each download button
  2. The paging iteration; although I'm assuming things here

Rows iteration

For this first requirement, you'll need to:

  1. Map the web element; in this case, the "Generate PDF" button
  2. Edit the selector by toggling "Custom" at the "Selector builder" window and changing the selector to a dynamic approach
  3. Count the number of rows: here you can do it either by retrieving the data table and counting its rows or JS
  4. Iterate each row to click the download button

Here's an example:

Button selector

Dynamic selectorDynamic selector

JS

Sample JS: replace querySelectorAll reference with you button pathSample JS: replace querySelectorAll reference with you button path

Sample flow

Sample flow - add whatever steps needed to each file downloadSample flow - add whatever steps needed to each file download

 

Page iteration

The same principle could be applied here, meaning:

  • You'll need to map the first element
  • Change it to a dynamic approach
  • Count the number of occurrences
  • Iterate them

Here's the part I say I'm assuming things:

You probably have a single row element (tr tag) with each page link in different columns (td tag). Then your dynamic part will be the <td> tag for this solution part. But the main logic remains the same.

Sample paging - single row with each link on different cellsSample paging - single row with each link on different cells

Pro tip: to better organize your code, I'd recommend separating those two parts in different modules (subflows):

Within the page iterator, you call the rows iteratorWithin the page iterator, you call the rows iterator

 

Thanks. This may be an appropriate solution, but it looks like I'd already need to be a Power Automate pro just to follow the instructions so maybe this is beyond my skill level. When I try to map a web element, it does not give me an option to enter the text you provided in any dynamic selector. The only selection for elements that I can do is the one that highlights the element in red. I also don't see anywhere in the sample flow you provided that shows where that dynamic selection takes place. I appreciate your response though! It may be helpful to someone else who searches for the same thing later on.

Hi @joshlwulf 

 

The dynamic selector happens in two steps:

  • In the object reference itself, through the row index: the tr:eq(%i%) means that instead of fixing an index, it will assume any value in the %i% variable

At the red square you can choose the variable to be used to dynamically reference each rowAt the red square you can choose the variable to be used to dynamically reference each row

  • And finally in the loop, where it starts in 0 and increments one by one until the last index is reached

Sample flow: add necessary steps inside the loop for each fileSample flow: add necessary steps inside the loop for each file

This means that each loop iteration will select a different row:

  • When it starts, %i% = 0 then the first button is pressed; PAD interprets as [...] > tr:eq(0) > td > button
  • At the next iteration, %i% = 1 then the second button is pressed; PAD interprets as [...] > tr:eq(1) > td> button
  • The next one, %i% = 2, third button is pressed; PAD interprets as [...] > tr:eq(2) > td > button
  • And so on

 

To manually edit the selector to add a variable in it, you'll need to toggle the "Custom" option in the "Selector builder" screen:

The default selector: eq() value is fixed and you want to change to a dynamic approachThe default selector: eq() value is fixed and you want to change to a dynamic approach

 

Thanks! I figured out how to find Selector builder and I think I now understand everything that your steps are supposed to accomplish. I think now I just have syntax errors. You said "Sample JS: replace querySelectorAll reference with your button path". This is my path from the Selector builder: table[Id="tblRslt"] > tbody > tr[Class="ng-star-inserted"]:eq(%i%) > td[Class="ng-star-inserted"]:eq(8) > button[Class="generate btn btn-link btn-sm"][Type="submit"], but when I try to replace querySelectorAll with that, I just get an error on the next step that it "Can't convert text '' into a valid number (text provided is either in a non-recognizable format or contains too many characters)." 

 

Here's the exact function I'm trying to run: 

 

2021-08-13_18-53-44.png

Hi @joshlwulf 

 

Sorry, my bad. There were some stuff I missed. So the first one is if you have an iframe in your target website then you should use the "iframe.contentWindow" prefix. If not, then you could go with only using querySelectorAll. Second, what you need to replace is the querySelectorAll content. Third, in here you can only use CSS selectors. The final code should look something like this (for a non-iframe website):

tkuehara_2-1629118292897.png

 

No need to apologize! The only way I even had a chance of figuring this out was with your help. I appreciate all of your effort!

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,085)