Micro Focus QTP (UFT) Forums
Selecting values from drop down using QTP. - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Selecting values from drop down using QTP. (/Thread-Selecting-values-from-drop-down-using-QTP)



Selecting values from drop down using QTP. - prempujaripati - 02-22-2013

Hi There
I want to select all the values one by one and select one value from the drop down list.So How can I write the code for the particular?
As I have written the code as
Code:
Browser("...:=...").Page("..:=..").Frame("..:=..").WebList("..:=..").Select "somevalue1"
Which will select that particular value from the list but I want to check with all the values and select one from them.

Thanks
In Advance.


RE: Selecting values from drop down using QTP. - basanth27 - 02-25-2013

Is this what you are looking at?

Code:
StrAllItems = Split(Browser("...:=...").Page("..:=..").Frame("..:=..").WebList("..:=..").GetRoProperty("All Items"),";")

For intCounter = Lbound(strAllItems) to Ubound(strAllItems)
   If Browser("...:=...").Page("..:=..").Frame("..:=..").WebList("..:=..").GetItem(intCounter) = "SomeValue" Then
            Browser("...:=...").Page("..:=..").Frame("..:=..").WebList("..:=..").Select (intCounter)
            Exit For
          Else
              msgbox "value not found...Please write a reporter event for this"
         End If      

Next

Or

Code:
iTemCount = Split(Browser("...:=...").Page("..:=..").Frame("..:=..").WebList("..:=..").GetRoProperty("Items Count")

For intCounter = 0 to iTemCount - 1
        If Browser("...:=...").Page("..:=..").Frame("..:=..").WebList("..:=..").GetItem(intCounter) = "SomeValue" Then
            Browser("...:=...").Page("..:=..").Frame("..:=..").WebList("..:=..").Select (intCounter)
            Exit For
          Else
              msgbox "value not found...Please write a reporter event for this"
         End If      

Next



RE: Selecting values from drop down using QTP. - rasmirani - 06-26-2014

Hello basanth27,
This Code is not working for me. It shows "The statement contains one or more invalid function arguments." in this line
Code:
Browser("...:=...").Page("..:=..").Frame("..:=..").WebList("..:=..").GetItem(intCounter) = "SomeValue"


So, please help ASAP.