Micro Focus QTP (UFT) Forums
for loop - 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 (/Thread-for-loop--6673)



for loop - sia sharma - 08-09-2012

Hi All,

i have page which contains pagination.
and i want to search a particular category in the pages.
the logic goes link this
can i use 'for' or 'for each' instead of 'if'


Code:
A = Browser("abc").Page("pqr").Link("Pubs").GetROProperty("text")'If  A.Exist Then
function(call)
else
Browser("abc").Page("pqr").Link("2").Click
If  A.Exist Then
function(call)
else
Browser("abc").Page("pqr").Link("3").Click
If A.Exist Then
function(call)
else
Browser("abc").Page("pqr").Link("4").Click
If A.Exist Then
function(call)
else
Browser("abc").Page("pqr").Link("5").Click    
If  A.Exist Then
function(call)
else
Reporter.ReportEvent micFail,"invalid","category not found"
End if
End If
End If
End If
End If



RE: for loop - ksrikanth2k9 - 09-13-2012

Code:
counter=0
for i=1 to 10
A = Browser("abc").Page("pqr").Link("Pubs").GetROProperty("text")
if A="some value" then
set obj= description.create
obj("micclass").value="Link"
obj("attached text").value=i
function(call)
counter=1
else
Browser("abc").Page("pqr").Link(obj).Click
end if
loop

if counter=0 then
Reporter.ReportEvent micFail,"invalid","category not found"
end if


it might help .....''