QTP code If condition question
	
    
    Purpose of the script is:
1. Take value from the datatable
2. Take row value from the application. Values are displayed in a webtable
3. Compare both the values 
4. Come out of the For loop when they match or else continue with the loop till the last row 
Code is:
If Browser("A").Page("B").WebTable("C").Exist Then 
        TotalRows = Browser("A").Page("B").WebTable("C").RowCount
End If 
Datatable_value = datatable("Datatable_value ", dtglobalsheet) 
msgbox"Datatable_value " &Datatable_value
For i = 2 To TotalRows 
        Row_Value = Trim(Browser("A").Page("B").WebTable("C").GetCellData(i,2))
        msgbox" Row_value" &Row_Value 
        If Datatable_value = Row_Value Then 
 
Browser("A").Page("B").WebTable("CF").ChildItem(i,2,"Link",0).click
        
                Exit For 
        End If 
NEXT 
 when the two values match instead of coming out of the For loop, it continues displaying the values till the last row. 
Please give some suggestion to ensure that the If condition works.
Thanks in advance
Tulip	
	
	
	
		
	
		
    
Questions by Tulip
	
    
          
              
            
              
                         
              
                    
              
              
     
    Showing Answers 1 - 4 of 4 Answers
			
				
				
       
       
		    
    
    
        
			
    
        
			
	
		
	
 
          
              
        
              
                      
              
                                   
  
                        
        Related Answered Questions
          
           
                              
            	
		Related Open Questions
		  
		   
	      
                       
  
                         
                    
            
QTP code If condition question
1. Take value from the datatable
2. Take row value from the application. Values are displayed in a webtable
3. Compare both the values
4. Come out of the For loop when they match or else continue with the loop till the last row
Code is:
If Browser("A").Page("B").WebTable("C").Exist Then
TotalRows = Browser("A").Page("B").WebTable("C").RowCount
End If
Datatable_value = datatable("Datatable_value ", dtglobalsheet)
msgbox"Datatable_value " &Datatable_value
For i = 2 To TotalRows
Row_Value = Trim(Browser("A").Page("B").WebTable("C").GetCellData(i,2))
msgbox" Row_value" &Row_Value
If Datatable_value = Row_Value Then
Browser("A").Page("B").WebTable("CF").ChildItem(i,2,"Link",0).click
Exit For
End If
NEXT
when the two values match instead of coming out of the For loop, it continues displaying the values till the last row.
Please give some suggestion to ensure that the If condition works.
Thanks in advance
Tulip
Questions by Tulip
Related Answered Questions
Related Open Questions