Extract "value" from select option list

I need to get the “value” from each option within a select list on a web page. I intend to iterate over each value, and perform an action. Currently, I have a “Find Children” activity for the selector, and a loop to get the “value” but I cannot get it to work. I can see the “aaname” attribute, and using UI Explorer, I can see there is a “value” attribute, but cannot seem to select it.

Example HTML:

<select id="accountNumberSelect" name="accountNumber">
	<option value="">All Accounts</option>
	<option value="123">123 - Account Name 1</option>
	<option value="456">456 - Account Name 2</option>
	<option value="789">789 - Account Name 3</option>
</select>

Example of output from “Get Children”:

UiElement[7] { UiElement { ClippingRegion=null, Selector="<html app='chrome.exe' title='View Invoices' />
<webctrl id='accountNumberSelect' tag='SELECT' />
<webctrl aaname='All Accounts' tag='OPTION' />" }, UiElement { ClippingRegion=null, Selector="<html app='chrome.exe' title='View Invoices' />
<webctrl id='accountNumberSelect' tag='SELECT' />
<webctrl aaname='123 - Account Name 1' tag='OPTION' />" }, UiElement { ClippingRegion=null, Selector="<html app='chrome.exe' title='View Invoices' />
<webctrl id='accountNumberSelect' tag='SELECT' />
<webctrl aaname='456 - Account Name 2' tag='OPTION' />" }, UiElement { ClippingRegion=null, Selector="<html app='chrome.exe' title='View Invoices' />
<webctrl id='accountNumberSelect' tag='SELECT' />
<webctrl aaname='789 - Account Name 2' tag='OPTION' />" }, UiElement { ClippingRegion=null, Selector="<html app='chrome.exe' title='View Invoices' />
1 Like

After Finding the children you will have to apply for each loop on each element and in that loop try to use GetAttribute activity and supply Attribute Name as “aaname”

Thanks for your reply, but sorry, I don’t understand…

See this working example -

Main.xaml (7.5 KB)

Getting dropdown values from this https://www.w3schools.com/bootstrap/bootstrap_dropdowns.asp website for test

image

1 Like

HI @PrankurJoshi, for the same requirement, I want to extract the dropdown data and need in the format of datatable, this is the website, https://www.x-rates.com/
And I tried but for testing purpose put it in the following excel sheet, am not able put in the correct format.

Main (12).xaml (9.2 KB)

dropdownlist.xlsx (12.1 KB)

Thanks in advance.

How to extract the value of selected drop down item?
Can someone help me

Hi Prankur and experts,

I have followed the file attached and I could extract the list items as well.Thanks! But I am having difficulty in clicking on the item during iteraion.
Capture

I want to click on the value in the dropdown list. Can you please help. I have tried to work with get text and get element only to conclude that result is not achieved.

Hi,
I want to get all the dropdown values in excel in particular cell and then want to select each drop down value one by one. And after selecting it I also want to verify selected values and mention as Pass or fail in excel.
For that do we need to add one more Foreach loop or how I will achieve it?

Hi,
I want to get all the dropdown values in excel in particular cell and then want to select each drop down value one by one. And after selecting it I also want to verify selected values and mention as Pass or fail in excel.
For that do we need to add one more Foreach loop or how I will achieve it?

Thanks Bro I got solution:star_struck::star_struck:

1 Like