Micro Focus QTP (UFT) Forums
For Loop Execution - 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: For Loop Execution (/Thread-For-Loop-Execution)



For Loop Execution - Ravi_Chandra - 01-18-2011

Hi,

I created external Data Table and placed 2 records in the Excel Sheet.

I inserted a For Loop in my function and called those parameters. But while execution, QTP is running more than 2 times. My external data sheet is having only 2 records.

Why QTP is running more than twice??
Below is my sample function:

Quote:Public Function Sample()

Datatable.AddSheet "Test_Data"
Datatable.ImportSheet "C:\QTP\Test_Data.xls", "Test_Data", "Test_Data"
Rc = Datatable.GetSheet("Test_Data").GetRowCount

For i = 1 to Rc

DataTable.GetSheet ("Test_Data").SetCurrentRow(i)
Browser("XXX").Page("YYY").WebElement("ZZZ").SetToProperty "innertext", DataTable ("ABC", "Test_Data")
Browser("XXX").Page("YYY").WebElement("ZZZ").Click

Browser("XXX").Page("YYY").WebElement("ZZZ").WebButton("XYZ").Click
St = Timer
Browser("XXX").Page("YYY").WebElement("Loading...").WaitProperty "Visible", "False" //Is this statement correct?
Reporter.ReportEvent micDone, "Loading", "Loading completed"
Et = Timer
Rt = Et - St
Reporter.ReportEvent micPass,"Report Time", "Report is generated in: " & Rt & " Seconds."
DataTable("Report_Time", "Test_Data") = Rt

Next

DataTable.ExportSheet "C:\QTP\Test_Data.xls", "Test_Data"

End Function

Please help??

Thanks,
Ravi.


RE: For Loop Execution - manishbhalshankar - 01-18-2011

Hi Ravi,
Check your Test Settings. In the Run tab, select "Run one iteration only".