Micro Focus QTP (UFT) Forums
How to select a city from the dropdown - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to select a city from the dropdown (/Thread-How-to-select-a-city-from-the-dropdown)



How to select a city from the dropdown - yash - 09-10-2013

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 .

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



RE: How to select a city from the dropdown - ssvali - 09-10-2013

Once your condition is passed then select the city name

Code:
Browser("Kotak Credit Cards – Apply").Page("Kotak Credit Cards – Apply").WebList("City1").Select(i)

Once you select the city try to retrieve city name by using proper property name like "value"

Code:
City_Name = Browser("Kotak Credit Cards – Apply").Page("Kotak Credit Cards – Apply").WebList("City1").GetROProperty("value")



RE: How to select a city from the dropdown - Sreevidya - 09-30-2014

Hi,

I wanted to select a value from dropdown and my application which im trying to automate is a JAVA based one. So i tried to locate the object by its ID. I have filters for 4-Dot and 5-Dot
1) 4-Dot: VTRV say... if i enter this value the field refreshes and then i have to select the value from dropdown.
2) Then only, ill will be able to see the 5-Dot field.

Can you please help me with this.

Thanks
Sreevidya


RE: How to select a city from the dropdown - rameshrise3 - 10-28-2014

Hi Sreevidya,

If you have to select 2 List values, where 2nd is dependent on 1st.

Code:
Browser(".").Page("..").WebList("Listbox1").Select "Value1"
If Browser(".").Page("..").WebList("Listbox2").GetROProperty("all ietms") = ".........dependent values" Then
   Browser(".").Page("..").WebList("Listbox2").Select "whatever"
End If