Data from file not read after 1st row in For loop

I am running into an issue when running a test using a data file. My data file consists of 5 rows of data. My script has a for loop to read the data -

for (def row = 1; row <= findTestData(‘TestDataSources’).getRowNumbers(); row = (row + 1))
{

The issue is that after the script reads the first row and completes the test, the web page closes. The loop causes the page to open again to create another record. The focus does go on the first field to enter data. It never reads the data and skips all the fields that should have data written to them from the data file. No errors are generated but the values are never read from the file.

I changed the row variable to ‘2’ to see if it reads the 2nd row. It did read it but then was not able to read the 3rd row in the file when the script looped.

Any idea why the script cannot read any data after reading the row based on the row value?

David Labrie said:

I am running into an issue when running a test using a data file. My data file consists of 5 rows of data. My script has a for loop to read the data -

for (def row = 1; row <= findTestData(‘TestDataSources’).getRowNumbers(); row = (row + 1))
{

The issue is that after the script reads the first row and completes the test, the web page closes. The loop causes the page to open again to create another record. The focus does go on the first field to enter data. It never reads the data and skips all the fields that should have data written to them from the data file. No errors are generated but the values are never read from the file.

I changed the row variable to ‘2’ to see if it reads the 2nd row. It did read it but then was not able to read the 3rd row in the file when the script looped.

Any idea why the script cannot read any data after reading the row based on the row value?

Please adding your sample script if possible, I think it could be caused by your script in for loop.

you can use your for loop as :

for (row = 1; row <= findTestData('test_data_step1').getRowNumbers(); row++)
{your code here }

it this is not working, please, provide your script of the screenshot so that we can figure out the problem.

I too have the same problemfor (int rowNum=1;rowNum<=findTestData(‘supp var’).getRowNumbers();rowNum++)
{
WebUI.setText(findTestObject(‘Page_Manage Suppliers - Suppliers - Oracle _766534/input_Keywords_pt1_FOr11_FOSritemNode_procu_6fefd1’),
findTestData(‘supp var’).getValue(1, rowNum))

WebUI.click(findTestObject('Page_Manage Suppliers - Suppliers - Oracle _766534/button_Search'))

WebUI.delay(5)

WebUI.click(findTestObject('Object Repository/Page_Supplier Dashansh Verma - Suppliers - _605c1c/td_Supplier_xz0'))

WebUI.setText(findTestObject('Object Repository/Page_Supplier Dashansh Verma - Suppliers - _605c1c/input_Supplier_pt1_FOr11_FOSritemNode_procu_8adf8c'), 
    findTestData('supp var').getValue(25, rowNum))

WebUI.setText(findTestObject('Object Repository/Page_Supplier Dashansh Verma - Suppliers - _605c1c/input_Alternate Name_pt1_FOr11_FOSritemNode_b11802'), 
    findTestData('supp var').getValue(25, rowNum))

WebUI.click(findTestObject('Object Repository/Page_Supplier Dashansh Verma - Suppliers - _605c1c/span_Save and Close'))

}