DataTable Iterations in QTP 9.2

The datatable iterations for a global datasheet are defined under Table Settings (File > Settings > Run) and the default value is “Run on all Rows”. Quick Test gets the count of the number of rows within the global sheet and sets the iterations from 1 to Rowcount which is similar like a For Loop. For every iteration, it sets the value of ‘I’ as the active row.



The data table iterations for a local sheet are defined under Action call properties and the default value is “Run one Iteration only”.

Quick Reference:

Data Table Iteration for Global Sheet – File > Settings >Run Tab
Data Table iteration for Local Sheet – Action Call Properties (Keyword View > Actions > Action Call Properties > Run > Run on all rows.

When to use Local datasheet in QTP 9.2?


If you want only a particular action for n number of times then put that data in the local data sheet and set the test iteration to “Run for all Rows”. Set the Test Iteration for Global Sheet as “Run only one time”. Look at this scenario to under stand better. We will use the Flight Reservation Application as reference.

Action 1 – Invoke Flight Reservation Application.
Action 2 – Login to the Application.
Action 3 – Insert Order.
Action 4 – Close the Flight reservation Application.

Now set the Global Data sheet iterations to Run only one time (File – Settings – Run Tab – Run only one time). Put down all the data for insert order in the Action 3 local data sheet and you want to insert orders for many users. To do so set the local data sheet test iteration as “Run on all rows”. The reason for doing this is that by default the global data sheet test iteration is set as “Run on all Rows” and the local data sheet Test Iteration by default is set to “Run only one iteration”.

If these Test iteration values are not manually set for both Global and local data sheet then the test runs for 10 * 10 = 100 times. Let me explain this. If you want 10 insert orders to be done and because the test iterations are set by default what happens is that all the actions run for the first time and the insert order runs for 10 times taking values from the local sheet and since the run time data sheet is having 10 rows all the actions from 1 to 4 run 10 times and the action 3 runs 10 times each time making the script to run a total of 100 times.

We do not want to this way what we wanted is all the actions 1,2 and 4 should run one time and only action 3 should run 10 times and that is why we change the Test Iteration values from default to what we want.

Since there are default values set for global and local data sheet it always create a problem like what we have seen above. So when we want that different sets of data to be used we will set the global data sheet to “Run on one row” and local datatable to “Run on all Rows”.

11 comments:

Unknown said...

Hi,

Settings :
File -> Settings-> Run -> Datatable Iterations -> Run one iteration only.

Can you tell me how can i write the above settings with the help of code (which should be applicable for same action).

THanks in Advance.

Regards,

Prasad S

charles said...

RunAction "Action1", OneIteration

Anonymous said...

How to write the code for execute 2 row

jeya R

Anonymous said...

hi try this,

a=datatable("A", dtGlobalSheet)
b=datatable("B", dtGlobalSheet)

msgbox a&" "&b

Datatable.SetCurrentRow(2)

a=datatable("A", dtGlobalSheet)
b=datatable("B", dtGlobalSheet)

msgbox a&" "&b


-Shakthi

Anonymous said...

Default settings for local/action sheet is Run one iteration only,n for global sheet it is Run on all rows,

sharanya said...

To run for two rows try this
RunAction"Action1","1-2"
similar to case where we specify a particular number if it is for all rows
try this
RunAction"Action1",alliterations

Christián said...

Hi

I have a question. Let's said that you have the same scripts 20 times on Quality Center Test Lab. So basically QC puts (1)Flight, (2)Flights...etc. Then you have an external excel file(data)up to 20 rows.

So you have 20 instances of the scripts on QC Test Lab and 20 rows of data on excel file.

I want to execute from "Qc Test Lab" and I want each iteration retrieves only 1 specific row of the excel file.

how can I do that??

if any body can help me please let me know.
christianesl@gmail.com

Anonymous said...

Hello,
I Did a for i = to Rowcount, reading from Data Table. DataTable only has three rows. Why is it that when I run, it runs at least 6 times? How do I get it to run only three times? Any help would be appreciated.

David said...

Hi Christian:

You need to use the Data Table function to point to a specific row in the datasheet in order to run a specific row.

VISHAL said...

Im calling copy of LoginApp Action and passing parameters using datatable [local ]to it but after running the script it takes same username, password for all rows in datatble..
RunAction "Copy of LoginApp", allIterations ,DataTable(1, 3), DataTable(2, 3)

Unknown said...

Great Article I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because it becomes more and more interesting from the starting lines until the end. So Thank you for sharing a COOL Meaningful stuff with us Keep it up..!


SAP Training in Chennai

Post a Comment

/* Tynt Insight tracker ----------------------------------------------- */