Selecting an item from the weblist is tricky in QTP. We have a method - select to select a specific item from the weblist.
But the item value is case sensitive. That means if you have 2 items in the list say Buy and Sell , then below code will throw an error saying can not identify the specified item of type - listType.
objParent.weblist("name:=listType").Select "BUY" 'and not Buy
But if you use below code, it will work like a charm.
objParent.weblist("name:=listType").Select "Buy" ' and not BUY
To make the code more reliable we can use more improved code as shown below
itemToSelect = "BUY"
arrWeblistItems = split(objParent.weblist("name:=listType").GetROProperty("all items"),";")
For itemCounter =0 to ubound(arrWeblistItems)
If trim(ucase(arrWeblistItems(itemCounter))) = ucase((trim(itemToSelect))) Then
objParent.weblist("name:=listType").Select arrWeblistItems(itemCounter)
Exit for
End If
Next
This is how we can select the item from the combo box in QTP regardless of case-sensitivity.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts. You can write to me at reply2sagar@gmail.com
But the item value is case sensitive. That means if you have 2 items in the list say Buy and Sell , then below code will throw an error saying can not identify the specified item of type - listType.
objParent.weblist("name:=listType").Select "BUY" 'and not Buy
But if you use below code, it will work like a charm.
objParent.weblist("name:=listType").Select "Buy" ' and not BUY
To make the code more reliable we can use more improved code as shown below
itemToSelect = "BUY"
arrWeblistItems = split(objParent.weblist("name:=listType").GetROProperty("all items"),";")
For itemCounter =0 to ubound(arrWeblistItems)
If trim(ucase(arrWeblistItems(itemCounter))) = ucase((trim(itemToSelect))) Then
objParent.weblist("name:=listType").Select arrWeblistItems(itemCounter)
Exit for
End If
Next
This is how we can select the item from the combo box in QTP regardless of case-sensitivity.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts. You can write to me at reply2sagar@gmail.com
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs