Saturday, 2 April 2011

How to get current iteration number of QTP script?

QTP test can run several iterations.
By default, when you run a test with global QTP Data Table parameters, QuickTest runs the test for each row in the Data Table, using the parameters you specified.

For example, the following global QTP Data Table contains 3 rows:

The iteration number of QTP test can be specified in 'File/Settings.../Test Settings dialog', 'Run' tab:

If we run our QTP test with above settings (global DataTable & 'Run' tab), the test will pass 3 iteration.
So, the question is How to determine the current iteration number withing QTP script?

Answer: We can use the value of "TestIteration" environment variable - Environment("TestIteration").

This is a sample QTP script I use to demonstrate Environment("TestIteration"):
str = "Current QTP iteration: " & Environment("TestIteration") & vbNewLine & _
"Param1: " & DataTable("Param1", dtGlobalSheet) & vbNewLine & _
"Param2: " & DataTable("Param2", dtGlobalSheet)

MsgBox str
And the result of above QTP script is:

As you can see, QuickTest Professional script works correctly.
You can use this approach to determine the current iteration number of running QTP script.

SOURCE

0 comments:

Post a Comment

Apex Monkeys © 2008. Design by :Yanku Templates Sponsored by: Tutorial87 Commentcute Software blogs Computers Blogs