Micro Focus QTP (UFT) Forums
Data Table iteration question - 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: Data Table iteration question (/Thread-Data-Table-iteration-question)



Data Table iteration question - on9west - 10-26-2010

Nice to meet you all. I am new to QTP and I have a question and detail as:

I am using QTP 11 with powerbuilder add-in

Here is my case
I have 10 lines of code.
I have 30 rows in Data Table
I want to iterate line 3-7 30 times using Data Table as parameter
Line 1-2,8-10 execute one time only.

My problem is when I execute my qtp script, its iterate 30 times for line 1-10.

Please advise. Thank you.


RE: Data Table iteration question - KVK - 10-26-2010

Hi,

Set the test settings as "Run One Iteration Only"
Goto - > Test Settings ->RUN--> Select "Run One Iteration Only"

Here is the code,


Code:
' Line 1 to line 2 of your code

For i = 1 to DataTable.GetSheet("dtGlobalSheet").GetRowCount
    DataTable.SetCurrentRow(i)
'    Line 3 to Line 7 of your code

   Next

   ' Line 8 to line 10 of your code

The above code should work.. If you still have issues please paste the code that you are using

- Vinod


RE: Data Table iteration question - on9west - 10-26-2010

Thank you KVK. It works.


RE: Data Table iteration question - hamzaz - 04-12-2012

Hello,

I am a new User in QTP, I have a question.
Following is my Code.


Code:
1.    Browser("Xtra login page").Page("XTRA login page").WebEdit("userName").Set "Alex"
2.    Browser("Xtra login page").Page("XTRA login page").WebEdit("userName").Submit
3.    Browser("XTRA login page").Page("XTRA login page").Link("Manage Customer").Click
4.    Browser("XTRA login page").Page("XTRA").WebButton("Create New").Click
5.    Browser("XTRA login page").Page("XTRA").WebEdit("customerid").Set DataTable("CustomerID", dtGlobalSheet)
6.    Browser("XTRA login page").Page("XTRA").WebEdit("name").Set DataTable("UserName", dtGlobalSheet)
7.    Browser("XTRA login page").Page("XTRA").WebEdit("telephone").Set DataTable("TelePhone", dtGlobalSheet)
8.    Browser("XTRA login page").Page("XTRA").WebEdit("email").Set DataTable("Email", dtGlobalSheet)
9.    Browser("XTRA login page").Page("XTRA").WebEdit("address1").Set DataTable("Address", dtGlobalSheet)
10.    Browser("XTRA login page").Page("XTRA").WebEdit("zipCode").Set DataTable("ZipCode", dtGlobalSheet)
11.    Browser("XTRA login page").Page("XTRA").WebEdit("city").Set DataTable("City", dtGlobalSheet)
12.    Browser("XTRA login page").Page("XTRA").WebList("countryCode").Select DataTable("Country", dtGlobalSheet)
13.    Browser("XTRA login page").Page("XTRA").WebButton("Save & Close").Click

In this scenario I want to run line 1 and 2 only once and rest of the lines according to the Data Table data.
Kindly let me know Rolleyes


RE: Data Table iteration question - parminderdhiman84 - 04-12-2012

use the below code:

Code:
Browser("Xtra login page").Page("XTRA login page").WebEdit("userName").Set "Alex"
Browser("Xtra fake login page").Page("XTRA login page").WebEdit("userName").Submit
iRows=DataTable.getrowcount
For i=1 to iRows
   DataTable.SetCurrentRow(iRow)
  Browser("XTRA login page").Page("XTRA login page").Link("Manage Customer").Click
Browser("XTRA login page").Page("XTRA").WebButton("Create New").Click
Browser("XTRA login page").Page("XTRA").WebEdit("customerid").Set DataTable("CustomerID", dtGlobalSheet)
Browser("XTRA login page").Page("XTRA").WebEdit("name").Set DataTable("UserName", dtGlobalSheet)
Browser("XTRA login page").Page("XTRA").WebEdit("telephone").Set DataTable("TelePhone", dtGlobalSheet)
Browser("XTRA login page").Page("XTRA").WebEdit("email").Set DataTable("Email", dtGlobalSheet)
Browser("XTRA login page").Page("XTRA").WebEdit("address1").Set DataTable("Address", dtGlobalSheet)
Browser("XTRA login page").Page("XTRA").WebEdit("zipCode").Set DataTable("ZipCode", dtGlobalSheet)
Browser("XTRA login page").Page("XTRA").WebEdit("city").Set DataTable("City", dtGlobalSheet)
Browser("XTRA login page").Page("XTRA").WebList("countryCode").Select DataTable("Country", dtGlobalSheet)
Browser("XTRA fake login page").Page("XTRA").WebButton("Save & Close").Click
Next



RE: Data Table iteration question - hamzaz - 04-12-2012

Thank you Smile Its working fine.