Dropdown, find childrens and excel

I need to insert each item from a dropdown into an Excel spreadsheet, with each item placed in a separate row of the same column. I’ve used “Find Children” and “Get Attribute,” but it extracts all names as a single string separated by spaces, which makes it difficult to individualize them, especially for composite names like “United States,” for example.

image

Hi @Juliana_Brondino

You can use Select Item activity and pass CurrentRow("yourcolumnname").ToString

Below are the steps:
=> Use Read Range Workbook to read the excel and store the output in datatable say dt.
=> Use Use Application/Browser activity and indicate the web application screen.
=> Inside that use For Each row in DataTable to iterate through dt.
=> Inside For Each row in DataTable place Select Item activity and pass CurrentRow("columnName").ToString

You can continue with further process of entering data if you have.

Regards

@Juliana_Brondino,

Try following this approach:

  1. Use Find Children to get all Dropdown Ui Elements
  2. Use for each Loop to iterate through all the drop down items
  3. Use Get Attribute to get the text one by one
  4. Add the output to a string

Sample solution:

Sample code:
Main.xaml (11.1 KB)

Thanks,
Ashok :slight_smile:

Extracting the dropdown values:

Creating a DataTable from the resulting collection / list / array we do have several options. One of them could be:

And finaly write the datatable to Excel e.g with write range activity

Hello everyone, thank you very much for your help! I haven’t been successful yet. On my page the aaname is blank so I used “Items":

This way it pastes the content into Excel. It is a dropdown of 81 items but it pastes them all into the same excel cell. I’ve already tried doing a for each without success.

I used this video as a guide, but it uses aaname and I don’t know if that’s why mine isn’t working.

Hi @Juliana_Brondino

Could you please share with us the website from which you want to extract country names , so that we can figure out the issue and provide you possible fix .

Thanks

@Juliana_Brondino,

What logic you have here?

Looks like you are joining all the items into a single string and adding it as a single row to Datatable.

If my understanding is right, don’t join the items into single string. Instead iterate through each string item and use Add Data Row in this loop to add each item to datatable as separate row and then do write range.

Thanks,
Ashok :slight_smile:

There are two pages with two dropdowns. The first one is fixed, so I had no problems with it. I’m facing issues on the second page. On the second page, the number and names of the items vary, so I can’t make a fixed reference. I need to extract the name of each item to be able to go through the entire list and copy the content of the next page into an Excel file.

I have completed the rest of the automation successfully. However, due to these variations, I am trying to adapt based on the dropdown content.

Regarding the Assign activity: the “items” obtained in the Get Attribute activity are in a list of strings, and the values are separated by commas. So, in the Assign activity, I separate them by “\tab”.

This is the first real automation I’m doing in UiPath, so I’m encountering some difficulties.

https://www.vestibularfatec.com.br/demanda/

Thank you again for your attention and help.