Count the number of times the object appeared in the run - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Count the number of times the object appeared in the run (/Thread-Count-the-number-of-times-the-object-appeared-in-the-run) |
Count the number of times the object appeared in the run - yonobev - 10-07-2009 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 RE: Count the number of times the object appeared in the run - basanth27 - 10-07-2009 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. RE: Count the number of times the object appeared in the run - qtpdeepak - 10-07-2009 Hi, As Basanth said you can use the Counter Variable. Below is a sample code from Flight Reservation Application, which gives the useage of Counter variable in Reporter Events. Also, you can see the Screen Shot which gives the No. of Pop-Up's displayed for each Pop-Up Dialog's. Code: Dim a,k Cheers, Deepak.Bhandarkar RE: Count the number of times the object appeared in the run - basanth27 - 10-07-2009 @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. RE: Count the number of times the object appeared in the run - qtpdeepak - 10-07-2009 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 RE: Count the number of times the object appeared in the run - yonobev - 10-08-2009 Hi! Thanks for all your help, but Basanth is correct. The code only repeats the entire loop and iteration. What I need to know is how can I show in the results that a particular window appeared nth times. Here goes the scenario. I have an action that iterates 4 times when I run. This is because I have 4 sets of data. And for each iteration, a dialog box maybe displayed depending on the value inputted. I want to know how can I count the number of times that particular dialog box appeared in the run and display it (count) in the result. Below are some lines from the codes: Code: If JavaWindow("WINDOW_NAME").JavaDialog("DATA").Exist Then Please advise. Thank you! Yono RE: Count the number of times the object appeared in the run - basanth27 - 10-08-2009 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 ? RE: Count the number of times the object appeared in the run - yonobev - 10-08-2009 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 RE: Count the number of times the object appeared in the run - Saket - 10-08-2009 Hi Yonobev, Please create a new thread for your new query. always make a habbit to put one query per thread. Thread closed |