Do While Loop With Condition to download attachment

Dear all,

Currently i am trying to download the attachment in the website as per screenshot below:
image

I am using the do while loop method and assign activity to download all the attachment. However, i dont want to download everything in the browser, i want to exclude those description with " Other" from downloading.

May i know how can i do that and sorry that if this is simple question as i still quite new on the Uipath.

Many thanks

Hi @SH_94 ,

You can use a Get Text inside that Do while loop to get the description for the current row.
The selector for this activity needs to be dynamic for tableRow number for example, in which you need to assign a contor that is incremented at each loop.

After getting the needed text then you can check wheteher it is equal to “Other” or not with an if activity, and based on that you can download it or not.

Hi @Catalina_Rs ,

May i know how to do the following action? If i want to exclude more items, like " Others" and " Unsigned", how to make it in this case?

“After getting the needed text then you can check whether it is equal to “Other” or not with an if activity, and based on that you can download it or not.”

many thank for your assistance

You can do as in the image below

First you need to identify the number corresponding to your first row, which is not always 1, in my example I have used a table that starts with rows from number 2 so my contor is initialized to 2.

The selector for Get text should look like this:
image

In the tablerow field you have to pass the contor variable to check the description for each row.
After getting the text in the if condition is verified whether it is in those two cases mentioned above. If it is true than don’t save the file, in the other case Click save.
It may be necessary to use a dynamic selector for Click save also, by passing the contor in the tableRow field.

After verifying this condition you need to assign contor+1.

In the Do While you need to put the maximum rows that are visible on that page as a condition

Hi @Catalina_Rs

Many thanks for the guidance.

I am trying to replicate the same thing. But it prompt out the error after reaching row 21 as row 21 onwards got nothing ady. It is because i set the condition less than 24.

image

May i know how to fix this in this case?

It is a selector error.
If you verify in Ui Explorer it validates the selector from the error message?

You need to adjust the selector to match all the visible descriptions but with the contor assigned in the TableRow field.

Hi @Catalina_Rs ,

May i know how to do the following:
“You need to adjust the selector to match all the visible descriptions but with the contor assigned in the TableRow field.”

Thank you.

You can omit the css-selector and the src link, and verify inside the UiExplorer if it is valid.
These fields may change so it is better to omit them.

After that you can verify in the UiExplorer if the resulting selector is valid for all the elements on that column by changing the tableRow index.
If the result is valid for all the occurences you can pass the selector to your activity but with the tableRow index replaced by the contor variable.

Hi @Catalina_Rs ,

I have deleted the CCS selector but remain the SRC selector.

The error still appear as below. May i know how to encounter this error or is there any things that i need to fix?

image

Thank you.

It seems like there is a problem with the TableRow number for index 13.

Because I cannot view the page, the only suggestion I could give to you is to adjust the selector from the error message by clicking repair and indicating the row on which the error occured.

Regards

Hi @Catalina_Rs ,

There is no row 13 for this particular search …reason being it appear because i put the do while condition loop until row 23.

Thank you.

In this case you need to change the condition to the max number of rows visible.
If there are 11 rows visible you need to put the condition contor<11.

Hi @Catalina_Rs ,

May i know if there is way to make it more dynamic? cz different search result it different number of row.

Thank you.

You can use ElemenExist activity to verify if that element on that specific row exists or not.

For example if there are 13 rows use elementexist with the same selector for GetText and in if activity check if it is true or false, if it is true then proceed with the other actions, if not, this means you passed over the last row item, in this case, 14.

In the Do While Condition use ElementExistVariable=True to work only if the row number exists.

Regards

1 Like

Hi @Catalina_Rs ,

Great suggestion, i also plan to do this one but i not sure how to do it in the complex way.

Basically now i plan to restructure the process as follow

  1. Detect the element exist for the first row (save button) ,
    2.1. if yes for element exist, then check the condition whether have the wording " Other" or “Unsigned”.
    2.2 If no element exist , then go to second row.
  2. If wording consist of "other " or “unsigned” , skip and go to the second row
  3. If wording does not consist of "other " or “unsigned” ,click the save button.

May i know how you will build in this case? Could you show me the screenshot on how to do this?

Many thanks in advance

This is what I intended earlier:

If it is helpful you can use this method.
Thank you.

1 Like

Hi @Catalina_Rs ,

Many thanks for the screenshot. Can i check with you on few things as follow:

  1. For screenshot above part, it will check for each row until the end right?Meaning if the dont have element exist , it will check for next row until the row (set by condition)?


2. While for this part, the condition we set as True . May i know the rationale behind on this? Is it more suitable than we set number of row in this case?

Many thanks again for the design…It really a brilliant design and dynamic.

Thank you.

  1. ElementExists outputs true if the element is found on the screen, in our case it searches for each description text on the row, beginning with row 1, 2,… and it ouputs false when the element is not found. In this case, as shown in the screenshot, that means that we have reached the end of the table, we have passed over the maximum nr of rows, because at each step we increment the contor used in our dynamic selector.

  2. The condition is RowDescription=True because we need to perform the actions inside the Do While loop only if the element is visible, if it turns False then we need to exit the Do while loop because we don’t have any rows left on the screen to process.

1 Like

Dear @Catalina_Rs ,

Many thanks a lot for your help and detail explanation. It works finally.

I have been thinking of this since last week on how to solve this obstacles and finally it is solved with your great help.

Thanks again and have a good day

1 Like

Dear @Catalina_Rs ,

Can i ask one more question on the file description which contains " Others" and “Unsigned”.

I saw youtube have many ways to keep it more dynamic. In my case, the number of unwanted wording will be less than 10.

May i know how you will do in this case? Maybe more unwanted wording to be add in the future.Could you share with the screenshot on this?

Thank you.