Thursday 20 February 2014

How to Select an item from the weblist in QTP?

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

No comments:

Post a Comment

Please Leave your reply. We value your feedback and inputs

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.