Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Looping and DataTable within the QTP forums, part of the Software Testing category; Hey, I am trying to loop through a set of steps X number of times and each iteration the test is supposed to extract(output) data into the datatable. The problem ...
|
|||||||
|
|||
|
Hey,
I am trying to loop through a set of steps X number of times and each iteration the test is supposed to extract(output) data into the datatable. The problem is that if I set the loop to run 10 times it runs ten times but it records over the last run's data. I'm using: For i=1 to 3 Step1 Step2... Next To run the loop 3 times. But I only end up with one row of data in the DataTable because each loop records over the last loop's data. I tried using DataTable.SetNextRow, but it didn't work. Any ideas? Thanks. Last edited by Davis2sa; 07-01-2009 at 10:45 AM. |
| Sponsored Links |
|
|||
|
Re: Looping and DataTable
Hai friend,
File-> settings->Run->Run one iteration only->Apply-> ok. Dim i For i=1 to Datatable.GetRowCount //steps here Datatable.SetNextRow Next Now run your scripts and let me know. Thanks Deepa |
|
|||
|
Re: Looping and DataTable
This would work if I had existing data in the data table that I was running the test with. But I am starting with a blank datatable. I want the steps in the test to repeat 10 times and each time it should pull a number into the datatable. So, after the test is completed I should have 10 rows, 1 number in each row. But I only end up with 1 number in 1 row because the numbers just get written over the previous run's number.
|
|
|||
|
Re: Looping and DataTable
Hai friend,
Ok initially you have blank datatable and you need to insert value in runtime into the datatable to perform iteration. Datatable.ImportSheet "C:\Documents and Settings\Deepa\Desktop\Abc.xls",1,1 Note: This excel Abc.xls should contain the value to iterate. The statement given above will insert the value into the datatable in run time and then use the below code and settings File-> settings->Run->Run one iteration only->Apply-> ok. Dim i For i=1 to Datatable.GetRowCount //steps here Datatable.SetNextRow Next I hope this helps thanks, if not then tell me clearly what you are expecting. Thanks Deepa Last edited by deepasree; 07-29-2009 at 05:58 AM. |
|
|||
|
Re: Looping and DataTable
Hey,
Why don't you try this Firstly declare the no of rows in the datasheet and Every time you retrieve the data from wherever you want it , set that to that particular row in which iteration the test is running currently. |
|
|||
|
Re: Looping and DataTable
How would I declare the number of rows that should be in the datatable?
Deepasree: I am starting with a blank datatable. I don't want to import an excel file. One step in my test is to output a certain value to the datatable. I want to run this test and end up with 10 different rows of data. So, datatable after test should look like this: Output Value 100000456 100000789 100000433 100000453 100000457 100000367 100000119 100000444 100000458 100000459 Right now it looks like this: Output Value 100000459 Notice it's the last value output because it writes over the first row each time the steps loop. Hope this is more clear. Thanks for your help. |
|
|||
|
Re: Looping and DataTable
There are many ways of solving problem. It's nice to have code/logic from other to plug in your test but you will not learn unless you attempt to solve your problem or take code/logic from other to evaluate or experiment.
1) prepare you dataTable 2) for i = 1 to 10 dataTable.value(your value) Datatable.SetNextRow Next OR row = 1 do while row < 10 dataTable.setCurrentrow(row) dataTable.value(your value) row = row + 1 loop 3) after the loop, you can save the datatable Last edited by learqtptesting; 07-30-2009 at 09:14 PM. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DataTable Question | Davis2sa | QTP | 5 | 06-15-2009 09:24 AM |
| Auto looping of the Script | Hobqtplearner | QTP | 2 | 05-23-2008 02:11 PM |
| How to do looping for consecutive rows? | coolkrish | QTP | 1 | 05-09-2008 06:49 PM |
| How to achieve looping in C++ | Lokesh M | C and C++ | 0 | 09-05-2007 05:43 AM |
| Can we implement a cursor looping logic | JayaSravani | Data Warehousing | 0 | 07-25-2007 12:36 AM |