0
votes

I am working on a UFT script that reads the values from a global data sheet and inputs the value to a textbox and then performs a verification. But the script reads only the first value and not the rest of the values in the column (and runs the same value 6 times). I know I am missing something basic but can't put my finger on it; can you please help?

length (data table)
-100
200
100.01
0
100
25

Here is the code:

<opens the number dialog>

data_length = DataTable.GetRowCount 'returns 6 

for i=1 To data_length

swfWindow("main_client").SwfWindow("tallyDialog").WinEdit("Current Value: -000.00).Set DataTable.Value("length") 'expecting it to read and input first value.

swfWindow("main_client").SwfWindow("tallyDialog").ActiveX("Enter") 'click enter

avg_length = swfWindow("main_client").SwfWindow("tallyDialog").Check (Checkpoint("Value must be from 0 to 100))

If avg_length then

reporter.reportEvent micPass, "test passed"

Else

reporter.reportEvent micFail, "test failed"

End if

Next

I was expecting it to do this iteration for all 6 values in the length table but it is doing this iteration 6 times for the first value (-100) What am I missing?

changing "run on all rows" to "run only one iteration" in the UFT settings also did not work.

1

1 Answers

0
votes

There are a couple of issues to look at here. Here's some code that will do what you need, followed by an explanation.

Firstly, set your test to run only one iteration, since you are looping through the data table in this one iteration. If you were to avoid the loop in the code, then you could set it on "Run all rows" and it would iterate through the data table.

<opens the number dialog>

data_length = DataTable.GetRowCount 'returns 6 

for i=1 To data_length
    DataTable.SetCurrentRow(i)
    swfWindow("main_client").SwfWindow("tallyDialog").WinEdit("Current Value: -000.00).Set DataTable.Value("length") 'expecting it to read and input first value.
    swfWindow("main_client").SwfWindow("tallyDialog").ActiveX("Enter") 'click enter
    avg_length = swfWindow("main_client").SwfWindow("tallyDialog").Check (Checkpoint("Value must be from 0 to 100))
    If avg_length then
        reporter.reportEvent micPass, "test passed"
    Else
        reporter.reportEvent micFail, "test failed"
    End if
Next

Note the DataTable.SetCurrentRow command at the start of the loop, which sets the datatable row to the loop index i. This ensures that each time around the loop, the datatable picks up the correct data item for the iteration of the loop.

Give this a try and if you are still having issues, post a comment with your problem and I'll try to help further.