09-10-2013, 03:06 PM
Hi Ankur,
I have a doubt for my code -- To select a city from the dropdown using VB script in QTP
Suppose if i want to select Noida from the dropdown list , using object spy i see the selected_item_index=13
and after selecting the city it must be displayed in a msgbox .. what should be the correct code -
The first half shows the total items present in the list and if Noida is present or not.
The second half as expected must select the city Noida and display in msgbox which is not working .
I have a doubt for my code -- To select a city from the dropdown using VB script in QTP
Suppose if i want to select Noida from the dropdown list , using object spy i see the selected_item_index=13
and after selecting the city it must be displayed in a msgbox .. what should be the correct code -
The first half shows the total items present in the list and if Noida is present or not.
The second half as expected must select the city Noida and display in msgbox which is not working .
Code:
city_found = "City Not Found"
total_item_list = Browser("Kotak Credit Cards – Apply").Page("Kotak Credit Cards – Apply").WebList("City1").GetROProperty ("items count")
Msgbox total_item_list
For i = 1 To total_item_list
city_name = Browser("Kotak Credit Cards – Apply").Page("Kotak Credit Cards – Apply").WebList("City1").GetItem (i)
If city_name = "Noida" Then
Msgbox "Pass"
city_found = "City Found"
Exit For
End If
Next
Msgbox city_found
selected_city=Browser("Kotak Credit Cards – Apply").Page("Kotak Credit Cards – Apply").WebList("City1").GetROProperty ("selected_item_index")
Msgbox selected_city