dynamically getting combo box info for select
I have an application which populates a combo box based on $$ info from an account. That $$ amount in the combo box changes based on how much money is in the account.
HTMLBrowser("Caption='Credit Union e-Branch - Transfers - Make Transfer'").Attach
HTMLComboBox("Name=fromAccount").Select "Money Market I (S/060) - $2,800.00"
HTMLComboBox("Name=toAccount").Select "Checking - $2,145.76"
HTMLEditBox("Name=AMT").Click 42, 6
HTMLButton("Caption='Preview Transfer >>'").Click
because the $$ amount is populated in the html as part of the name of the combo box, if the $$ amt changes, so does the combo box selection availabilities.
How do I "get" the combo box options, so that I can do a "select" on them? Is there a way?
Re: dynamically getting combo box info for select
Here is an example of how to get the items into a collection/array and work with them this way. In your case though... it sounds like you need to do some math calcuations in your script to determine what the possible options would be in order to select them.
' Attach to Caption='QA Forums: dynamically getting combo box info for select'
HTMLBrowser("Caption='QA Forums: dynamically getting combo box info for select'").Attach
theIndex = GetComboItem("f", "TestPartner") 'call function pass the name of the combo and what you want to select
HTMLComboBox("Name=f").SelectIndex theIndex 'Now select by index
Public Function GetComboItem(ComboName As String, ItemToSelect As String)
Dim theChoices As TItems
Dim o As Object
Dim theOptions(100) As String ' if combo can be bigger, raise number
Set theChoices = HTMLComboBox("Name=" & ComboName).Items
' The number of items is....
' MsgBox "There are " & theChoices.Count & " options in the combo"
X = 0
For Each o In theChoices 'each choice in the combo
If o.Item(1) = ItemToSelect Then
GetComboItem = (X + 1)
X = X + 1
'You could also have put the items into an array and returned it.