Micro Focus QTP (UFT) Forums
How to get list items based on selection - 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 get list items based on selection (/Thread-How-to-get-list-items-based-on-selection)



How to get list items based on selection - Sireesha Bodha - 02-03-2010

Hi Ankur,

I am Sireesha. I got a doubt regarding how to write script to select an item from Flights table based on Fly From and Fly To selection criteria.
I have parameterized Fly From and Fly To values, Flight table list items and entered values in Data Table. But based on the Fly From and Fly To selection in flight table some list items will be displayed.But in Data Table i can give only one value(but that is also not recognized by QTP while running becoz of random population of list items in Flights table)

I wrote following script but i am getting errors. Please help me on this regard.

Code:
Dim i, introwcount
InvokeApplication("D:\HP\QuickTest Professional\samples\flight\app\flight4a.exe")
Dialog("Login").WinEdit("Agent Name:").Set "training"
Dialog("Login").WinEdit("Agent Name:").Type  micTab
Dialog("Login").WinEdit("Password:").SetSecure "4b6840b3fe5f9a3c3048beca56289b582c098a99"
Dialog("Login").WinButton("OK").Click
introwcount=Datatable.GetRowCount()
For i=1 To introwcount
Window("Flight Reservation").ActiveX("MaskEdBox").Type "110211"
Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable("fly_from", dtGlobalSheet)
Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable("fly_to", dtGlobalSheet)
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select DataTable("List", dtGlobalSheet)  
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "siri"
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinButton("Button").Click
Datatable.SetNextRow
Next

Plz tell me where ever modifications required. i donno much on Vb script.
Thanks in advance.


RE: How to get list items based on selection - sreekanth chilam - 02-03-2010

Hi ,

Try with the below way & execute.

Code:
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select 0

Note: As it would select 1st item in the list for all rows irrespective of flight selection(Fly From & Fly To ) and hence there would be no issues.Smile