Regular Contributor.. jayraocourts Regular Contributor..
Regular Contributor..

Data not reading passed row 1 in For Next Statement


I have a datatable being read from external xlsx file; This reads fine, and places the 3 rows of data in the Global Sheet.

My issue is that when it runs, it only recognizes the first row of data , enters data into the 2 fields, but then continuously  runs that row several times then exits the test( function); can anyone suggest why its not reading or entering all the rows?

FYI - * Table is 2 columns , 3 rows

script running below:

datatable.Importsheet "C:\Users\jayrichardson\Desktop\Data10.xlsx",1,"Global"

msgbox L ( place this to just verify it sees correct number of rows = 3)

    For B = 2 to L 
Browser("A").Page("B").WebEdit("Input field").Set datatable.Value("Value 1")
Browser("C").Page("D").WebList("Input Select field").Select datatable.Value("SelectValue1)

 If Browser("E").Page("D").WebButton("Add ").Exist Then
 End If       


2 Replies
Knowledge Partner
Knowledge Partner

Re: Data not reading passed row 1 in For Next Statement

If you are importing the sheet you should control the iteration through the datatable in the script, something like:

rc = DataTable.GetRowCount
DataTable.SetCurrentRow = 1
For i = 1 To rc
    ' Do stuff
    DataTable.SetNextRow 'Goes to the next row

Mark Smith.


Micro Focus Contributor
Micro Focus Contributor

Re: Data not reading passed row 1 in For Next Statement


Did you checked your test settings run options? You can get to them by right clicking your test in solution explorer, choose test settings from the context menu. In test settings window click Run options. There is a setting for Data table iterations, make sure option: Run on all data rows is chosen. 

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.