开发者

is there a method in qtp to check whether the item exists in Combo box?

开发者 https://www.devze.com 2023-01-08 02:22 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消