Firstly, if your test is set to Run on all rows
in File
->Settings
->Run
then you do not require the loop you have in the code - UFT
knows it needs to iterate for each row in your data table.
Secondly, all you need is the statement followed by a check on its success and any error handling. IN the event of the error, just exit the test iteration, and UFT
will move onto the next one.
My reworked version of your code:
Browser("ABC").Page("ABC").WebEdit("ABC").Set "123" ' sets an initial value
Browser("ABC").Page("").WebEdit("ABC").Set DataTable("DT1", dtGlobalSheet)
If Browser("ABC").Page("").WebEdit("ABC").GetROProperty("value") <> DataTable("DT1", dtGlobalSheet) Then
' Handle error popup if it exists
Browser("ABCError").Page("").WebButton("OK").Click
ExitTestIteration
End If
Browser("ABC").Page("").WebEdit("CDE").Set DataTable("DT2", dtGlobalSheet)
If Browser("ABC").Page("").WebEdit("CDE").GetROProperty("value") <> DataTable("DT2", dtGlobalSheet) Then
' Handle error popup if it exists
Browser("ABCError").Page("").WebButton("OK").Click
ExitTestIteration
End If
Browser("ABC").Page("").WebEdit("FGH").Set DataTable("DT3", dtGlobalSheet)
If Browser("ABC").Page("").WebEdit("FGH").GetROProperty("value") <> DataTable("DT3", dtGlobalSheet) Then
' Handle error popup if it exists
Browser("ABCError").Page("").WebButton("OK").Click
ExitTestIteration
End If
Browser("ABC").Page("").WebEdit("JKL").Set DataTable("DT4", dtGlobalSheet)
If Browser("ABC").Page("").WebEdit("JKL").GetROProperty("value") <> DataTable("DT4", dtGlobalSheet) Then
' Handle error popup if it exists
Browser("ABCError").Page("").WebButton("OK").Click
ExitTestIteration
End If
Browser("ABC").Page("").WebEdit("MNO").Set DataTable("DT5", dtGlobalSheet)
If Browser("ABC").Page("").WebEdit("MNO").GetROProperty("value") <> DataTable("DT5", dtGlobalSheet) Then
' Handle error popup if it exists
Browser("ABCError").Page("").WebButton("OK").Click
ExitTestIteration
End If
I have assumed that your repeated setting of Statement 1 etc in the question is supposed to emulate setting a number of different WebEdit
text boxes and coded 5 sets as an example. If, as the iteration progresses, any of the text boxes is not set to the specified data table column value (DT1 to DT5 in my example) then the If
condition will be satisfied, causing the attempt to handle an error popup (you'd need to amend my guessed code to suit your requirements) followed by the exiting of the test iteration. Exiting the iteration will trigger a new one to be started, so just be sure you handle any error popup before you exit.
If all WebEdit
s are completed successfully, then UFT
will just repeat for all iterations defined in your data table.