I have written the following code to get all the elements in the combo and check with my required value, but i think there may be a better way. Whats the better method to check if any item is there in a combobox? couldnt get from the QTP help.
For check_index=0 to Window(window_name).Dialog(dialog_name).WinComboBox(control_name).GetItemsCount-1
If Trim(Window(window_name).Dialog(dialog_name).WinComboBox(c开发者_运维百科ontrol_name).GetItem(check_index))
=Trim(input_value_array(i_count)) Then
There is no such method out-of-box. You'll have to create your own function.
If you don't care, what item was or will be selected, try this:
' try to select the desired value
yourCBO.Select "my item name"
' if it could be selected, then it does exist...
If yourCBO.GetSelection = "my item name" Then
MsgBox("exists")
Else
MsgBox("doesnt exist")
End If
精彩评论