Update a column in the data file that is already data bound to the test case

I have an excel file that I bound to a test case for iterating through test data. After each row, I want a column in the data file to be updates with a status like Pass or Fail. I added a column Pass/Fail to my excel spreadsheet and also added a variable called Pass_Fail in the test case(maybe not needed). How can I update the excel file with a Pass or Fail in that column?

I want to be able to do something like -
Datafile.setValue(‘Pass/Fail’, ‘Pass’) 'for that current row

Can someone help me for syntax for this scenario?

The following doc may help:

thanks Kazurayam. I already checked this. As per this code, I need to invoke the file and figure out the row and column and then add that value. But since I already have the data file bound to my test case, I want to be able to just call the Pass/Fail column for the current row it is running and update it.

I see that there is a findTestData object and was wondering if I can use that for this scenario.

Did you ever figure this out? I’m writing a file from one test suite that needs to be used by the next test suite in the test collection, and it’s pulling the original values.

I don’t want to add code to consume the test data, at the very least I would expect the test data to refresh between test suites (even it not between test cases in same test suite.).


I was not able to use the Test Data to do it. But I added code in the Test Listener to save to the Excel file. As soon as the TC is done for that iteration, I use the ID created for the account and a Pass/Fail Variable and save it to the Test file. So the Datafile is updated after every iteration. Below is the code on how I do it in Test Listener. I search for the row in the Test File using one of the values in the variables, in my case below it is the email. Hope this helps.

def sampleAfterTestCase(TestCaseContext testCaseContext, TestData testData) {
String accexcel=“C:\xxxx\xx.xlsx”
String ContractNumber = GlobalVariable.ContractNumber
String PassFail
String ErrorMsg = GlobalVariable.ErrorMsg

		switch (testCaseContext.getTestCaseStatus()) {
				case 'FAILED':
					PassFail = "Fail"; 
				case 'ERROR':
					PassFail = "Fail"; 
				case 'PASSED':
					PassFail = "Pass"; 
		XSSFWorkbook workbook1 = ExcelKeywords.getWorkbook(accexcel)
		XSSFSheet sheet1 = ExcelKeywords.getExcelSheet(workbook1, "ISA Bulk Certification")
		String studentEmail = testCaseContext.getTestCaseVariables().get("StudentEmail")
		int rowIndex = ExcelKeywords.getRowIndexByCellContent(sheet1, studentEmail, 5)
		if (ContractNumber == null) { ContractNumber = "Student is not created" }  			
		ExcelKeywords.setValueToCellByIndex(sheet1, rowIndex, 0, ContractNumber)
		ExcelKeywords.setValueToCellByIndex(sheet1, rowIndex, 1, PassFail + " - " + ErrorMsg)
		ExcelKeywords.saveWorkbook(accexcel, workbook1)