How to correctly loop through an HMTL UL element with For Each

Hi there!

I’m trying to loop and click through a series of items on a website which are inside a UL element.

The HTML is as follows:

<ul id="network-list" class="network-list network-list-icons navigation clearfix">
   <li id="network-1" class="network network-item navigation-item cursorPointer ajaxNetwork first">
      <input type="hidden" value="1"/>
   <li id="network-2" class="network network-item navigation-item cursorPointer ajaxNetwork ">
      <input type="hidden" value="2"/>
   <li id="network-3" class="network network-item navigation-item cursorPointer ajaxNetwork ">
      <input type="hidden" value="3"/>
   <!-- and so forth, there are 17 more of these -->

So, basically, clicking each one of these would lead to additional actions, namely downloading files. I’ve put these inside a For Each activity, looping as “For each network in networkList”, with networkList as an IEnumerable variable.

However, all I get is the loop constantly clicking the very first item. On my Selector I have this:

<webctrl css-selector='body&gt;div&gt;ul' id='network-list' parentid='main' tag='UL' />
<webctrl id='network-*' tag='LI' />

But I’m not sure if the id='network-*' bit is correct.

Any inputs, hints or general advice on where to find more info on this will be appreciated.

Thanks in advance!


Hi @david.martinez,

You can put int variable=1 and incremental one by one like counter.


Omkar P

Hi, usually this is best done using Find Children activity, please look at it:

Hi, @Reddy_Paluri && @bcorrea, thanks for your feedback.

Unfortunately I still can’t seem to make this work.

I had already added a Find Children pointing it to the UL element, and with FIND_DESCENDANTS as the scope. The output is the networkList variable which I mentioned above, but the For Each activity keeps on clicking just the first LI element.

As for @Reddy_Paluri’s suggestion, I’m not sure where to place such a variable and how to link it to my For Each loop.

I’ll keep on researching this, but will appreciate any further guidance.


The return of the find children should be used in a for each, and you would send every item to the element variable of a click activity…

Thanks for the hint! I was doing just that, but instead of using the element variable I was using the selector field. Now it seems to be moving forward. I’ll continue working on it, as this is just the first step of many, but at least we seem to be passing the first roadblock.

Thanks again, very helpful.

1 Like