Micro Focus QTP (UFT) Forums

Full Version: Verifying the contents of a Web List in QTP scipt
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

Please can any body tell me the code in QTP(vb script) to verify the items of a Web List.

e.g. If I need to select ABC items in Web List and before selecting that item I want to verify that whether that item exist in Web List or not.

Regards,
Ritu
Code:
listval = browser("name").Page("name).WebList("name").GetROProperty("all items")

listvalues = split(listval,";") ' u ll get all weblist values in listvalues array.

use this aray and check whether ur item is thr in the list or not

Correct if m wrong. even i am new to QTP.

Regards,
Mallesh
Hi ,

Use the below code.
Code:
Expected_Item="ABC"
  Items_count=Browser("....").Page(".....").WebList("select").GetROProperty("Items Count")
  For i=1 to Items_count
       Current_Item=Browser("....").Page(".....").WebList("select").GetItem(i)
       msgbox Current_Item
       If Current_Item=Expected_Item Then
            msgbox "expected item exists in WebList"
            Browser("....").Page(".....").WebList("select").Select Expected_Item
            Exit for
       End If
  Next
You could simply do something like this:

Code:
vendorListItems = Browser("...").Page("...").WebList("...").GetROProperty("all items")
If Not instr(vendorListItems, VendorNameToSearch) > 0 Then
    Msgbox "Vendor Name not found"
End If
ExpectedResult="Sales"
ItemCount=Browser("OrangeHRM").Page("OrangeHRM_2").WebList("leaveList[cmbSubunit]").GetROProperty("all items")
itensplit=split(ItemCount,";")
For i = 1 To UBound(itensplit) Step 1
actualResult=Browser("OrangeHRM").Page("OrangeHRM_2").WebList("leaveList[cmbSubunit]").GetItem(2)
If actualResult=ExpectedResult Then
MsgBox "Elemet Found"
Browser("OrangeHRM").Page("OrangeHRM_2").WebList("leaveList[cmbSubunit]").Select "Sales"
Exit for

End If

Next