Error trying to write in the following row after every iteration (test suite)

Error trying to write in the following row after every iteration (test suite).
How i can bind the row number?
I want to write the following row after every test suite iteration.

Here is the test case Im trying to implement and doesnt work because the type of
variable ‘RowVar’ Im trying to bind.

WebUI.openBrowser(URLs)
WebUI.delay(2)
TextOne = WebUI.getText(findTestObject(‘Page_Log in/h1_Welcome to’))
println(TextOne)
FileInputStream file = new FileInputStream(new File(‘F:\Testdata.xlsx’))
XSSFWorkbook workbook = new XSSFWorkbook(file)
XSSFSheet sheet = workbook.getSheetAt(0) // Get the first sheet.
‘Write data to excel’
sheet.createRow(RowVar) // New
sheet.getRow(RowVar).createCell(RowVar).setCellValue(TextOne)
file.close()
FileOutputStream outFile = new FileOutputStream(new File(‘F:\Testdata.xlsx’))
workbook.write(outFile)
outFile.close()
WebUI.closeBrowser()

Here is the Katalon error related with this.

Any suggestion? PLease help.
NOTE: Im not a programmer. Just a Functional tester.

The clue is in the error:

image

‘Write data to excel’
sheet.createRow((int) RowVar)

I’m a little concerned about where RowVar comes from but based on the error, that’s what you need.

It PASSED but didnt write any data in the spreadsheet


the modified test code is this:

WebUI.openBrowser(URLs)
WebUI.delay(2)
TextOne = WebUI.getText(findTestObject(‘Page_Log in/h1_Welcome to’))
println(TextOne)
FileInputStream file = new FileInputStream(new File(‘F:\Testdata.xlsx’))
XSSFWorkbook workbook = new XSSFWorkbook(file)
XSSFSheet sheet = workbook.getSheetAt(0) // Get the first sheet.
‘Write data to excel’
sheet.createRow((int) RowVar) // New
sheet.getRow((int) RowVar).createCell((int) RowVar).setCellValue(TextOne)
file.close()
FileOutputStream outFile = new FileOutputStream(new File(‘F:\Testdata.xlsx’))
workbook.write(outFile)
outFile.close()
WebUI.closeBrowser()

That’s why I questioned where RowVar comes from.

Be aware, I am not familiar with the XSS APIs, so it’s hard for me to be definitive about answering your questions. That said…

RowVar seems to appear out of nowhere. Ideally, there should be a line of code somewhere that looks like this:

int RowVar

If you had that line, then you would not need to say (int) before RowVar.

Then, somewhere else, there should another line where a value is placed in RowVar like this:

RowVar = 42 // or the result of calling something

sheet.getRow((int) RowVar).createCell((int) RowVar).setCellValue(TextOne)

This looks wrong. Why would you pass a row index to a cell?

RowVar is just a number

that should be the index for the getRow() and createCell() I defined that in the data file of the test suite (data binding)

I thought can be stated or declared as getRow()variable) createCell(variable)

should i have to define RowVar somewhere else ?

I have no idea. This is out of my field.

You should read the documentation for Excel integration and Data driven testing.

https://docs.katalon.com/katalon-studio/tutorials/data_driven_testing.html