Extract "value" from select option list


#1

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' />

#2

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”


#3

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


#4

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