I have a list box which contains duplicate values e.g.
A,A,A,B,B,B,C,C,C.Now write a code in qtp to test the list
box .
Scenario #1 : I have to check whether any values are there?
Scenario #2 : If duplicate values are there,then how many
time it is getting duplicated?
Svenario #3 : how can I test presence of items in list box
ommiting duplicate values?

Answers were Sorted based on User's Feedback



I have a list box which contains duplicate values e.g. A,A,A,B,B,B,C,C,C.Now write a code in qtp t..

Answer / m.ganesh


ItemsCount=Browser("creationtime:=0").page("title:=.*").WebList("name:=lccp_src_stncode").GetROProperty("items
count")
print "items count"& ItemsCount

if (ItemsCount)<>0 then

print "this is Items Count"&ItemsCount

End If

-Ganesh

Is This Answer Correct ?    5 Yes 0 No

I have a list box which contains duplicate values e.g. A,A,A,B,B,B,C,C,C.Now write a code in qtp t..

Answer / guest

Note : You need to take all the options of the weblist into
an array and try this logic

arr=array(1,2,4,1,2,6)
cnt=0
For i=0 to ubound(arr)

For j=0 to ubound(arr)
If i<>j Then
If arr(i)=arr(j) then
print arr(i)&"is repeated"
End if
End If
Next
Next

-Ganesh

Is This Answer Correct ?    4 Yes 1 No

I have a list box which contains duplicate values e.g. A,A,A,B,B,B,C,C,C.Now write a code in qtp t..

Answer / sayani sur

Ganesh thanks for the answer but please provide clarification for below....

1. Can I use childobject.AllItem in place of getROProperty(items Count)?

2 . as u told i have to store all weblist items into an array..will u please tell me how can i insert these values/weblist items into an array...

Is This Answer Correct ?    1 Yes 0 No

I have a list box which contains duplicate values e.g. A,A,A,B,B,B,C,C,C.Now write a code in qtp t..

Answer / bhargavi

A small change is required in the logic.

arr=array(1,2,4,1,2,6)
cnt=0
For i=0 to ubound(arr)
For j=i to ubound(arr) <-- Not j=0 but take j=i so that comparison will not be repeated
If i<>j Then
If arr(i)=arr(j) then
print arr(i)&"is repeated"
End if
End If
Next
Next

Is This Answer Correct ?    1 Yes 0 No

I have a list box which contains duplicate values e.g. A,A,A,B,B,B,C,C,C.Now write a code in qtp t..

Answer / ss

If duplicate values are there,then how many
time it is getting duplicated?

ItemsCount=Browser("creationtime:=0").page("title:=.*").WebList("name:=lccp_src_stncode").GetROProperty("allitems")

For i=0 to ubound(ItemsCount)
For j=i to ubound(ItemsCount)
If arr(i)=arr(j) then
print arr(i)&"is repeated"
End if
Next
Next

Is This Answer Correct ?    0 Yes 0 No

I have a list box which contains duplicate values e.g. A,A,A,B,B,B,C,C,C.Now write a code in qtp t..

Answer / aparajit

Thanks Ganesh its a good logic

-Aparajit

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More QTP Interview Questions

What is XML checkpoint in QTP. How we can use in Web Based application

2 Answers   LinkEdge,


How u call functions in QTP

5 Answers   Lehman Brothers,


hi all, I want to know about the QTP scripts, i have read more books but all areis to be a theory so how can i improve my script skills. if anybody knows about qtp scripts plz guide me and i need a sample scripts.my mail id is karthis4u@gmail.com, 9986667831 If you all have any data send it to akadi111@gmail.com

3 Answers  


hi i have one isuue on selecting webcheckbox .there are 15 wecheckboxex i want to select every time 9 th one how can i select plese help me regards balaji

4 Answers  


How to find duplicates in an array and remove them efficiently?

2 Answers  






whenever U using QTP,Test Director, Why we using separate Bug tracking tool?

1 Answers  


HoW to open QTP in Real time.after getting the qtp window how to log in .pl answer real time people

3 Answers   GE,


Please clarify Automation and QTP both(names) are same or diff?

1 Answers  


Hi all im having a pop up validation browser which is 20 in number, i want to close those similar pop browsers one after the other, is there any specific code for that? i tried by giving creation time & putting in a loop but it dint work? valid working answers will be greatly appreciated

2 Answers   McAfee,


Explain data driven framework?

0 Answers  


We need to verify the user name & password in for the user validation. But we don't want to use the parameterization/ loop for user name and password. What is the way in scripting so that user & password will generate automatically.

11 Answers   Tech Mahindra,


what is spy, and how can u use?

1 Answers  


Categories