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 - 6 of 6 Answers

adisgee

  • Jul 11th, 2007
 

Ideally the code should be working fine, but since it is not as you mention, a temp work around can be:
Within the "if loop", after you perfrom the desired operation, add a statement, i = TotalRows + 1. This will stop the "for loop" from executing, once the If condition is satisfied : ). Not a good prog practice but effective as a temp work around. 

Thanks,
Aditya.

  Was this answer useful?  Yes

pooja0981

  • Jul 6th, 2008
 

I am using IE.Visible = TRUE property.but i am facing problem is that when I am running the IE aplication,form is displayed for a sec and it disappears, is there any way to dusplay the form other then Wait()

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions