Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Logic doubt
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,
In my application we are having values as links in grids with pagination based on the records in the DB.
I need to find a value in the grid and click to do actions.The value that i want to search may be in the first page or in any where in the pages of the application.
1.Values for search wil be given in the QTP datatable.
2. i am getting the total no.of pages, starting from the first page i am getting the total records inside the page ( Grid).
3. then i am comparing the search value with the grid value if matches then run some statements and then it should exit from both loops and start from first line of code for the second given value.

The following is my code:
Code:
row = DataTable.GetSheet("Global").GetCurrentRow
Browserpage.Link("name:=1").Click  ' Clicks the first page
EmailId = DataTable.GetSheet("Global").GetParameter("EmailId").ValueByRow(row)
Pages = 3   ' getting during the run time
For i = 1 to pages
count = 5   ' getting during the run time
For j = 2 to count
    Tablelink = gridlist(3).GetCellData(j,1)  ' getting during the run time
  If   Trim(EmailId) = Trim(Tablelink) Then
   EmailID.Click
  Update.Click
Exit For    ' the control should exit from the inner loop
Exit For     ' the control should exit from the Outer loop and goes to the first line of code.
End If
Next
Browserpage.Link("name:=Next").Click  ' Clicks the next page.
Next

But the above code is not working as excepted.
Exit For for the inner loop is working but the outer loop is not working.
can anybody help me.
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Prema,
This will not quit from the outer loop.
Because "Exit For" transfers control to the statement following the "Next" statement, so your 2nd "Exit For" will never be executed.
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Try modifying your code as follows:
PHP Code:
Dim condition
condition 
0
row 
DataTable.GetSheet("Global").GetCurrentRow
Browserpage
.Link("name:=1").Click ' Clicks the first page'
EmailId DataTable.GetSheet("Global").GetParameter("EmailId").ValueByRow(row)
Pages ' getting during the run time '
For 1 to pages
   count 
' getting during the run time'
   
For 2 to count
      Tablelink 
gridlist(3).GetCellData(j,1' getting during the run time'
      
If Trim(EmailId) = Trim(TablelinkThen
         EmailID
.Click 
         Update
.Click
         condition 
1
         
Exit For ' the control should exit from the inner loop'
      
End If
   
Next
   
If (condition 1Then
   
Exit For ' the control should exit from the Outer loop and goes to  the first line of code.'
   
End If
   
Browserpage.Link("name:=Next").Click ' Clicks the next page.
Next 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Hiii. Could you clarify this doubt priya10it 5 3,507 11-21-2012, 10:04 AM
Last Post: priya10it
  Doubt on Object Repository Rajashekar Gouda 1 2,519 05-03-2008, 03:43 AM
Last Post: niranjan

Forum Jump:


Users browsing this thread: 1 Guest(s)