Problem with index on dynamic selector

attempting to progress row by row in a web UI dependent upon the number of download attachment links. Goal is to click on each link as long as index is <= row count as determined by how many times “Download” appears in an output from an output data table. Here is my selector on the first download link

<webctrl tag=‘A’ aaname=‘Download’ innertext=‘Download’ omit:tableCol=‘1’ omit:tableRow=‘1’ idx=‘1’ /

and the dynamic selector

<webctrl tag=‘A’ aaname=‘Download’ innertext=‘Download’ omit:tableCol=‘1’ omit:tableRow=‘1’ idx=‘{{rowIndex}}’ /

Where row index variable is original rowIndex set to 1 and rowIndex in a while loop set to rowIndex+1

However, in the UI there are 2 rows with “Download” in them and the automation translates my variable to idx ‘3’ after using the dynamic selector. It is not finding idx ‘2’.

What am I missing?

Hi chris,
I think instead of assigning variable to the idx assign it to the row index that might help.

Thanks Rohan. The table row does not increment. Only the idx increments.

Sorry am I clarifying something here? Your selector has tableRow attribute. When you check the selectors for row 1 and row 2, does the tableRow value show as 1 for both selectors?

Table row continues to show as tableRow1 for both idx 1, idx2, etc.

Let me expand on that. I can extract the structured data but when I attempt to count the data rows I get a message “there are no data rows”. Instead, I used a match statement to determine how many times “Download” appears thereby tell me how many times to progress the selector to click to different rows. So, the row does not increment although the idx does.

Ok, there is another way around it. Let us run with the fact that the idx does not increment in a contiguous manner.

Theoretically something like this below could work. But if a better solution is found, I would definitely prefer that.

First - you set up some loop and generate the selector for the download button by passing incremental values.

Once you have the selector, use the Find element and capture it into an element object > set the Continue on Error to true

If the Robot does not find an element matching idx=“2” then the element object will be set to Nothing . From your example it will fail to find idx=“2”, but it may find idx=“3”. The Robot will continue because Continue on Error is set to true

Next, in an if else statement you can validate if element object Is nothing.
If Nothing, then resume without clicking that element and increment to the next value
If Not Nothing, then pass that element to a click activity to initiate the download from the corresponding button.

Now, there is another challenge with this approach. You need to know when you will need to stop incrementing idx values. For that, if your page has listed the number of records found, you could scrape that information to get the total number of idx values you will need to increment to.

If that info is not available, you can try scraping only the first column of the HTML table and get that into a DataTable. The number of rows in the data table will be the maximum value of your idx increments.

Hope this helps

I did something similar. Although the dt that is extracted is not a true datatable, I was able to determine the number of times the word “Download” appeared using Match. For each single “Download” view, the table showed 2 so it is a 2 to 1 relationship so I divided by 2 and got the number of “rows” the bot would need to get a download from.

I then had a counter run through a get attribute looking for the idx of each of the items according to the number of times “Download” appeared and allowed the counter to run in a while loop to get idx numbers until it exhausted my number created from the Match activity. I then had the idx numbers and I used them in yet another loop to replace the idx number in the dynamic selector. The idx actually had no set pattern of incrementing that I could find and I am sure it is based upon the way the “table” appears on the UI. It is most likely the result of some underlying table merges in the application.

However, having the while loop with get attribute retrieve the idx numbers was successful and then using a separate loop to exhaust all identified idx numbers for the Download hyperlink allowed the bot to click on each row.


I do agree. Such kind of pages are difficult to automate. I ran into this issue with a subtitle creator where every text box had the same attributes . The other way I had hoped of resolving this was by tabbing my way into each text box before I typed into it. Fortunately, the application had a more traditional way of uploading information instead of typing them into each of the text boxes.

Thanks for sharing the solution :slight_smile: :+1:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.