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 / Link not consistently ...
Power Automate
Answered

Link not consistently clicked using 'get element on web page' and 'if web page contains'

(0) ShareShare
ReportReport
Posted on by 17

Hello all,

 

I am not sure what I need to change here so I am anxious for feedback.

 

I created a flow following some youtube videos. The flow works, mostly. Of 82 projects, it says that 70 have reports though only 34 reports were saved.  I watched the flow run itself and and saw that it would not automatically skip to the next project if the web page did not contain 'design report'. I also noticed that when it did have 'design report' it would freeze a little and then go to the next project without clicking on the link to the report.

 

I don't understand why some files were saved and some were skipped though they were present.

 

Snag_4caf522.png
Snag_4cae302.png
Snag_4cac8b3.png
  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If the element does not exist, Get details of element in web page will fail. As such, it will not update the %exists% variable, but your On block error will kick in, making it skip the rest of the steps in there and then write to Excel. But the value of %exists% from the last successful instance will always be written to Excel, unless you reset it in the On block error or somewhere else in the beginning of your loop.

     

    You don't really need to use Get details of element in web page, because the If web page contains does essentially the same thing. It checks if the web page contains the element. This is likely the part that actually makes it "freeze a little" for you. It is a slow way of doing it, but it would run slightly faster if you did not also have Get details of element in web page. Instead just set your %exists% to false by default at the beginning of your loop and set it to true inside the If web page contains condition. Set it by using Set variable. This will be simpler.

     

    The reason why it may sometimes "freeze a little" when it finds the report, but still not download it, is likely related to one of the selectors not working well. It sounds like the selector for checking if the report exists is actually fine. But maybe the link you're trying to click to actually save the report is failing on some instances. You should check what the selector for that link looks like on some reports that were skipped, by capturing it as a new selector, and compare it to the one you already have. See if there are some parameters that could be modified to make it work dynamically in all cases.

     

    See here for reference on how to modify selectors: https://learn.microsoft.com/en-us/power-automate/desktop-flows/build-custom-selectors

    Also this tutorial video: https://www.youtube.com/watch?v=2PcyBa22Jj8&ab_channel=Thomas%22Shaky%22Petersen

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • UshaJyothiKasibhotla Profile Picture
    229 Moderator on at

    Try with  if exists =%true%

    and please increase runtime delay and check.

     

     

  • helpmeautomate Profile Picture
    17 on at

    Hi Agnius,

     

    Your name must be true! Thank you for your reply.

     

    I have:

    1. Under the loop, set a variable for 'design report' = to 'false'.
    2. Moved the 'write to excel' under the on block error.

    These two actions made the robot just cycle from one project to the next. It did not stop at all for the design reports. I'm not sure what was happened. I copied the flow so I could keep in order what I knew worked somewhat yesterday and tried again.

     

    3. Reviewed some projects that had a design report but were not clicked and downloaded. As you mentioned, the format of the title of the report was different from the previous selector. I created new selectors.

      • 'SD-DRSummary'
      • 'Summary'
      • 'summary'
      • '_Summary'
      • 'Summary_'

    I was going to share this reply before I completed some extra troubleshooting: My question now is how do I create a loop for when the design report exists, for the robot to then go through each iteration of possible formatting, and then move to the next project? I think the UI element builder 'capture based on text; contains text' is case sensitive otherwise I would imagine it would suffice to just have the selector click on anything that says 'ummary.'  BUT! after watching the second link and doing some additional searches because I wanted to understand what I was doing/why (https://api.jquery.com/contains-selector/) I still don't understand what I did but it works to do just what I wanted it to do by using. :contains(XYZ) 

     

    I don't know what step I can delete to speed up the bot because each time I changed something, something else wouldn't work. That's why I put in the display message action to see that it was reading the 'design report' element. Once that worked correctly I turned it off and continued with the flow. The write to excel is still wonky because it has written true for both projects with and without design reports. ¯\_(ツ)_/¯ 

     

    Because I have the files I need, I will copy the bot again and create another flow to just search whether the design report exists or not without downloading it. I will try to figure out the variable issue there. THANK YOU SO MUCH for getting me in the right direction and helping me to understand what could be faulting my robot and how to think through a potential similar glitch in the future.

    Snag_7aa9ac.png
    Snag_7a876e.png
    Snag_7a5562.png
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    What you did with the selector is okay. The reason you still get "true" on reports that are not downloaded / do not exist is because you are still using Get details of element in web page inside the block and are not resetting the %exists% variable. What this means is that when the element does not exist, the %exists% variable is not set to "false". The action fails, and it will go to the end of the block because of On block error. So, the value of %exists% is either empty until the first report that exists, or is equal to "true" for every report after the first one that does exist.

     

    If you want to keep using Get details of element in web page the way you are using it now, you should at least reset the value of %exists% in the beginning of your loop to be equal to "false" or whatever you want it to write when there is no report to download.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • helpmeautomate Profile Picture
    17 on at

    Thank you again, Agnius. I'm not trying to be null but I am confused about where the write to excel is supposed to go alongside the %exists% variable. Is it supposed to go inside of the on block error at the bottom?  What do you mean by reset %exists%?

     

    I reread your first comment. I understand what you're saying but not how to execute it correctly.

    "If the element does not exist, Get details of element in web page will fail. As such, it will not update the %exists% variable, but your On block error will kick in, making it skip the rest of the steps in there and then write to Excel. But the value of %exists% from the last successful instance will always be written to Excel, unless you reset it in the On block error or somewhere else in the beginning of your loop."

     

    Same for this one-

    "The action fails, and it will go to the end of the block because of On block error. So, the value of %exists% is either empty until the first report that exists, or is equal to "true" for every report after the first one that does exist."

     

    The set variable %exists% is at the beginning of the loop. Do I put another set variable %exists% within the on block error as well? I tried this out and the robot went through the project numbers but did not click on the link for design report.  I disabled the get details of element and it just cycled (pic 1). I don't need the 'get details of element' but without it and just using the 'if web page contains' continues the cycling.

    Snag_59a95f7.png

     

    I turned off the if web page contains and used the get details of element. That worked, mostly, except for after it had found a design report and went to search the next project(pic2). It kept the label of 'FALSE' on the project with no design report when it should read 'TRUE' (that there is no design report)(pic3). I think the error now is still the placement of the %exists% variable but I don't understand why.  The robot wrote the correct value when there was a report and the set variable is active within the on block error and again under the for each.

    helpmeautomate_2-1698861978828.png

     

     

    Moving the get details element under the for each loop didn't fix the writing error.  Looking at the third picture with the excel snippet, the robot started out doing well but after the second false, it erred. The red X's should read 'true' so it worked and then didn't.

     

     

    helpmeautomate_3-1698862190644.png

     

     

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If you add another Set variable action to set %exists% to false at the end of your block, this will overwrite your Excel output. You do use Write to Excel worksheet twice - once when there is a report (inside the block) and once for every row (outside the block). When there is a report, both of these actions are run, but they both write the same value, so there's no issue. But if you use Set variable between them, you get the second Write to Excel spreadsheet action to write "false" on rows where a report was found, and that's incorrect.

     

    You only need to use Set variable once - to set %exists% to false in the beginning of the loop. You already have that and that's enough. You should remove the second Set variable action at the end of the block - you don't need that, and it's causing incorrect info to be written to Excel. If you remove that, it should work fine.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 377

#2
11manish Profile Picture

11manish 302 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 130

Last 30 days Overall leaderboard