Download from variable list of files

uiautomation
studio

#1

I need to download from a list of links from a website that vary on a daily basis. For example, today I can see the following

image

I need to click on each of the download links to download each of the files and save them

image

How can I loop through all the links?


#2

can u share website link


#3

It is a restricted website (https://copilote4.fineasy.com).

If it helps, the selector for the download button is as follows:

If I select the 2nd, the selector is as follows:

<html title='Copilote' />
<webctrl idx='2' parentid='content' tag='A' />

I guess I need a way to find out how many index links there are and then loop through them (somehow)


#4

You could try using FindChildren activity from the container (use the content element for it) with filter like <webctrl tag='A' />.
It will give you an Enumerable<UiElement> that you can ForEach through.


#5

@andrzej.kniola: thanks the the guidance.

I don’t seem to be able to find the children though.

See the XAML file attached. I’ve added a text box to show me how many items are found, but if finds none

Also, I’m attaching the html code that I think it is relevant to the download items in the website it helps to define properly the Find Children activity.

webSite.html (1.1 KB)
testting.xaml (13.6 KB)


#6

Thanks for the attachments, it helps to see the structure.

There seems to be a little misunderstanding on how to use FindChildren.
Selector property should point to the container, or in other words first common ancestor.
Filter property should describe what children/descendants you want to find.

In your attached workflow Selector is pointing to a link (or a) element already, and that has no children.

Set your Selector property to something like this (I’m guessing how it looks - check with UiExplorer)
<html title='Copilote' /> <webctrl aaname='content' tag='DIV' />

Set the Filter property to:
<webctrl tag='A' />

You could also check with Scope being FIND_DESCENDANTS instead of FIND_CHILDREN, depending on if it’s directly under your container or further down.
Try also searching for other topics with FindChildren, there were some examples somewhere on the forums.

Inside the ForEach don’t use selector in the Click activity - pass the item into Element property instead, so that it will use previously found element directly.

Let us know how it goes.


#7

Thanks @andrzej.kniola. I managed to do some progress with your advice.

I have found the children with "<webctrl />", but it founds 7 rather than 6 (there are 6 download links) With <webctrl tag='A' /> doesn’t find anything. I’ve tried to select different parts of the web site, but it didn’t make any difference. What I’m selecting now is the part of the screen where the download links are located.
image

Maybe web scrapping the page and counting how many ‘Download’ links I could find might help instead?

Selecting item into Element property gives me an error message.
image

I managed to make it work with a do while loop instead. The problem I have is that as it finds 7 elements it gives me an error at the end when trying to find and element that can not find.

testting.xaml (12.8 KB)


#8

Try with this one:
testting (1).xaml (14.3 KB)

I’ve added a childrenFoundArray = ChildrenFound.ToArray to be able to access via index and changed clicks and highlight to use prefound elements.
In the ForEach changed TypeArgument to UiPath.Core.UiElement - it was left as default (Object).

Also added a WriteLine with .Selector.ToString and innertext attribute in the loop and changed the condition a little (you can compare counts directly and string comparison would break if above 10 as with strings "2" < "10" = False). If all of them will return “Download” and the weird one will return something else, you could filter it out or omit in an If.

It’s interesting that it doesn’t find anything with tag ‘A’, as judging by the selectors themselves it should, or I’m missing something.


#9

Pertect!! Thanks @andrzej.kniola. This works very well. And thanks also for the .Selector.ToString tip. The process gets the headings, but like this I can exclude it and just pick up on the ones containing ‘Download’

Thanks again!!


#10

I tried your solution, but i can not write a line with .selector.toString. There is only “.select” expression, could you plz help me?


#11

I have the same issue with you but i can not write a line with .selector.toString. There is only “.select” expression. could you please tell me what should i do?


#12

Can you post a screenshot or your xaml?
Are you sure your element is of type UiElement?


#13

Ohhhh, thankU,!! As you said, my element is not a type of UiElement!! Now I solved my problems!