Complete a series of steps within an element of a web page, then repeat

Hi clever people!

I have a website that has one or more elements of the same class - let’s call the class ‘Fruit’ for now.
I need to iterate through however many class=fruit there are on the page. Within each ‘fruit’ I need complete a number of steps: click a button, get some text, enter some text etc.
I can iterate through uiElements with For Each UiElement, just fine, but what I want to do is be able to click on the button within each element - ie the button is a child of the UiElement of class ‘Fruit’ which I am iterating through. I keep ending up with it clicking the first ‘This is an Apple’ button on the page, rather than the one within my element.
Any ideas on how to achieve this?

Hi, @JohnMac To make each click and action target the right “fruit” element, use Find Children to get all the fruit sections, then for each one, use Click or Type Into with its parent set to the current fruit element. This way, your activities will only focus inside each fruit box and won’t jump to the first one every time. Works great for dynamic lists like this!

Thanks Arjun,
It is the bit where you say ‘use the click or type into with its parent set to the current fruit element’ bit that I’m struggling with. How do I set a parent for a click activity?

I know my profile says I’m a Bot Master, but I haven’t touched it for a few years, and a lot has changed in that time :smiley:

@JohnMac No problem Sir! In UiPath, after you use “Find Children” to loop each fruit, inside your “For Each UiElement” you can use Modern activities like “Click” or “Type Into” and set the “Target.Element” property (sometimes just called “Element”) to the current item from your loop. This targets everything inside that specific fruit. If you’re using Classic activities, look for “Element” or “Container” fields, and set those to your current UiElement. This is how you make sure each action only happens inside the right fruit box.

Use Find Children → get all fruit blocks.

Loop through each CurrentItem.

For every Click/Type/Get Text, set InputElement = CurrentItem.

@JohnMac

  1. Find children activity.. Input: currentElement ,filter <webctrl tag='button' /> can add any other attribute like innertext if you ahve multiple buttons
  2. output of find children use in the click activity output.first()

cheers