Posts: 11
Threads: 4
Joined: Oct 2009
Reputation:
0
10-07-2009, 09:01 AM
Hi All,
I have a problem in QTP. I want to count the number of times a particular object is shown during my run. Here is the scenario:
I have 4 sets of data in Data Table, 3 of which would give me a pop-up window during a run. Now, I want to return the number of times that pop-up window was showed when I click Run. I want the result displayed in the Results window.
Please help! Thank you!
Yono
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
10-07-2009, 11:33 AM
How do you handle the Pop-up ? Please paste your code so that we can see what help we can extend.
Maybe you can extend a counter variable which will hold the number of clicks and then write it to the Reporter statement.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
10-07-2009, 03:30 PM
@qtpDeepak - Please wrap your code whenever you post.
The solution you have provided is not correct. This will always print 1 popup for the first reporter, 2 for the second one irrespective of how many times it comes up. The reason being, If is a conditional loop which will enter only once. Your counter will take iterate only once depending upon the previous k value. Morever your counter is not capturing multiple occurences of the same popup during the same instance.
Iteration counters are in the logical loop, for Next and While wend or if you require in the run instance then the occurences of the object needs to be counted and stored in the variable separately.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 11
Threads: 1
Joined: Jun 2009
Reputation:
0
10-07-2009, 03:43 PM
Yeah Basanth, You're right. My script is capturing the No of Times the Pop-up's appears. It is not taking into consideration the Similar Pop-Up Objects.
I will try to learn this part as well. Thanks for guiding me on this one.
Cheers,
Deepak.Bhandarkar
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
10-08-2009, 11:07 AM
Yono -
You may want to store the counter variable value on to a cell in the datatable and for every iteration append it with the previous value. On your reporter pick the final value from the cell and write it on.
Does this logic help you ?
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 11
Threads: 4
Joined: Oct 2009
Reputation:
0
10-08-2009, 02:55 PM
Hi Basanth,
The logic looks fine, thank you. My problem now is how can I assign the variable to a cell. I'm really a newbie in QTP.
Thanks!
Yono
Posts: 1,199
Threads: 5
Joined: Nov 2008
Reputation:
0
10-08-2009, 02:58 PM
Hi Yonobev,
Please create a new thread for your new query.
always make a habbit to put one query per thread.
Thread closed