Micro Focus QTP (UFT) Forums
how to use looping statement - 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: how to use looping statement (/Thread-how-to-use-looping-statement)



how to use looping statement - dmvelic083185 - 09-26-2017

Hi, Good day to all, currently using UFT v14

I wanted to loop lines 1-13 using the data table which has 6 rows then after that run lines 14-16 once.
What statement would be best to use? currently it runs 6 times login to logout. Thanks in advance for your comments


Code:
1. Browser("VMware Service Manager").Page("VMware Service Manager").Link("Log a Call").Click
2. Browser("VMware Service Manager").Page("VMware Service Manager").Link("APAC").Click
3. Browser("VMware Service Manager").Page("VMware Service Manager").WebList("EXTFLDV_500064").Select DataTable.Value("EXTFLDV_500064", "Action1") 
4. Browser("VMware Service Manager").Page("VMware Service Manager").WebEdit("Contact_No").Set DataTable.Value("Contact", "Action1") 
5. Browser("VMware Service Manager").Page("VMware Service Manager").WebList("URGENCY_REF").Select DataTable.Value("URGENCY_REF", "Action1") 
6. Browser("VMware Service Manager").Page("VMware Service Manager").WebList("IMPACT_REF").Select DataTable.Value("IMPACT_REF", "Action1") 
7. Browser("VMware Service Manager").Page("VMware Service Manager").WebEdit("EXTFLDV_400136").Set DataTable.Value("EXTFLDV_400136", "Action1")
8. Browser("VMware Service Manager").Page("VMware Service Manager").WebEdit("HTMLTEXTAREA_PROBLEM_DESC").Set DataTable.Value("HTMLTEXTAREA_PROBLEM_DESC", "Action1")
9. Browser("VMware Service Manager").Page("VMware Service Manager").WebButton("Submit").Click
10.  If Browser("VMware Service Manager").Page("VMware Service Manager").WebElement("innertext:=A new call has been logged with the following details:").Exist(4)Then 
11.    Browser("VMware Service Manager").Page("VMware Service Manager").Link("Log a Call").Click
12. End If
13. Wait(2)
14. Browser("VMware Service Manager").Page("VMware Service Manager").Link("Log Out").Click
15. Browser("VMware Service Manager").Page("VMware Service Manager").WebButton("OK").Click
16. Browser("VMware Service Manager").CloseAllTabs



RE: how to use looping statement - Ankur - 09-26-2017

This is a classical UFT quiz/certification question Smile

Put login/logout data in global data sheet and rest of the data which needs to be repeated in action sheets.

So if you have to login once and then do iteration for 20 times and then logout. Put the login info once in global table, put 20 lines worth of data in action table and then a logout action.