cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Megachile
New Member

How to point PA to correct UI elements when URL changes

Hi all,

 

I'm a novice user of PowerAutomate with no HTML background. I've been playing around with PA Desktop's record tool and was able to build a flow that achieves what I want to do satisfactorily. The problem is that it is extremely fragile. If I make any changes to the URL of the site I'm working it at all, every single one of my actions needs to be edited to show them where the UI element is again using the Add UI Element tool. I'll give some more specifics below but the general question is, how do I write the command in such a way that PA can still find the same UI element in the same place on the page even if the URL has been slightly altered? The beginning of the URL will always be the same, and the tab will always have the same name, but the site uses the URL to store various filter changes I need to be able to use. 

I'm trying to create a hotkey-activated flow that will add a specific set of observation fields to an observation on iNaturalist. I will manually open a modal on the site and navigate to an observation that I want to run the flow on. example.JPG

 

I've got the hotkey-activation working with a loop starting with "wait for shortcut key"; the next step is to attach to a running instance of Microsoft Edge titled Identify · iNaturalist. This stores a variable "Browser". Then it needs to press the "Annotation" button, go to the "Observation Fields" text box, type some text, select the corresponding span below, go down to the selection box below, make a selection, and press the add button. The name and position of each of those UI elements is the same regardless of the URL, but PowerAutomate throws an error if I make any change to the URL, because it isn't finding the UI Element I've told it to look for using the Add UI Element tool.

 

How am I supposed to write the names of these things such that it will always know where they are? I mean that in both ways. I wouldn't know how to write the correct address for the UI element in HTML, but I also don't even see how you could write a custom address in PA at all. The edit function for a Press Button action, eg, only allows me to select UI elements from those I've already added, and I can't change them in any way. 

 

Thank you for any help you can give

1 ACCEPTED SOLUTION

Accepted Solutions
Megachile
New Member

I was able to achieve this using the "Run JavaScript function" action instead of the press button or focus field actions. I had to get some help writing the JavaScript but it works much more reliably this way.  

View solution in original post

2 REPLIES 2
Megachile
New Member

I was able to achieve this using the "Run JavaScript function" action instead of the press button or focus field actions. I had to get some help writing the JavaScript but it works much more reliably this way.  

Hi @Megachile ,

 

It seems to be an interesting scenario. Could you please share the JS codes, to help others find them when they need?

 

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

AI Builder AMA June 7th carousel (up on May 25th, take down June 8th) (1).png

'Ask Microsoft Anything' about AI Builder!

The AI Builder team invite you to ask questions and provide helpful answers at our next AMA.

Users online (1,580)