Description : Typically, when you visit a site and want to download an item, there is a unique html link for that item. Take for example the IRS Publications site in the image below:
The link behind each item in the table is as follows:
**(Inspector code behind IRS Publication site)
In a perfect world, if you were building an automation to navigate to each of these links, one approach you could take would be to extract this as a datatable or use the Find Children activity and pull the href links behind each of these pdfs. However, there are times where you may be dealing with a site where links aren’t as straightforward. Let’s say you visit a site and rather than all of the links being unique, they instead are something like this: (Irs-pdf | Internal Revenue Service) for each of the pdfs. So, your automation wouldn’t be able to visit each unique site. What do you do?
Potential Approach : One approach would be to use the browser inspector tool to take a deeper dive into the page code and find a unique element associated with the pdf. In some sites, a unique identifier may be buried deep in another class, for example a hyperlink class rather than an href class. Once you have that particular class that you’ve realized is the unique identifier for each link to the pdf, you have all the tools you’ll need to begin build your UiPath solution.
Building the solution :
You will need a Find Children activity in your solution. Depending on how deep the actual unique identifier is in your code, you will want to change the option on the activity from “FIND_CHILDREN” to “FIND_DESCENDANTS” or even lower. In my case, I was able to find my unique identifier using the “FIND_DESCENDANTS” scope
Next, you will want to specify the class that contains the unique identifier in your filter for the Find Children app, in my case, that class was the “blue hyperlink” class. So my filter looks like this: “” (which will vary depending on the coding of the page you’re using the activity on)
Now what you’ll need to do is save the results to a UiPath variable, I called mine “TestChild”
My next suggestion here is to test opening the selector on the browser page with the children and click the “Open in UI Explorer” link. I love this link because it shows you data from the particular page you’ve selected and allows you to explore the properties in an organized manner.
In the property explorer of the UI Explorer window, you can see the properties of the item you’ve interrogated based on the filter that you’ve entered. So my window view shows me all of the HTML elements of the blueHyperLink class I’ve selected, for example, the innerhtml, text, href, outerhtml values of that one blueHyperlink property from the page.
So, that was exactly the next property to be extracted as shown below:
Using the (Write Line) node the text value input is: item.Get(“href”).ToString
At this point you can test your automation by looping through each item in your table and printing out this line. This test gave me the values that I needed to move on to actually downloading my item.
- We need to save the item.Get(“href”).ToString to a variable in UiPath and we can replace the specific webctrl id value in the click Selector with the newly created variable, I named it “DownloadUniqueID”.
- In order to replace text with a variable in the selector tool, delete the text next to the value in the Edit attribute window, type Ctrl + k and select your variable.
Now you have an automation that will click the unique element to download your item, all you need to do is place this code within a For Loop (For each item in your variable storing the Find Children data) and let your automation run!