Hi knowledgeable people, me again!
I have finally managed to write (well, I borrowed someone elses test from here) a test that takes a bookingId and writes it to Katalon. The test runs with no failures but doesn’t stamp in excel. I ran the test with the “setText” bit and it errored but showed me that it had taken the bookingId. So I’m a little bit stumped as to why it didn’t stamp it in excel. So if anyone could point me in the right direction, I would be enterally grateful and make you some cake
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
import org.apache.poi.xssf.usermodel.XSSFCell as XSSFCell
import org.apache.poi.xssf.usermodel.XSSFRow as XSSFRow
import org.apache.poi.xssf.usermodel.XSSFSheet as XSSFSheet
import org.apache.poi.xssf.usermodel.XSSFWorkbook as XSSFWorkbook
import org.apache.poi.ss.usermodel.Cell as Cell
import org.apache.poi.ss.usermodel.Row as Row
//WebUI.getText(findTestObject(‘Search drop down/Page_Checkout/BookingID’))
String location = ‘C:\GIT\travel-katalon\Main branch\Data Files\BookingNumber.xlsx’
GlobalVariable.bookingId = WebUI.getText(findTestObject(‘Search drop down/Page_Checkout/BookingID’))
//WebUI.setText(findTestObject(‘Search drop down/Page_Checkout/BookingID’), GlobalVariable.bookingId)
/* open connection to MS Excel, save surname to sheet 1, cell A2, close connection */
FileInputStream fis = new FileInputStream(location)
XSSFWorkbook workbook = new XSSFWorkbook(fis)
XSSFSheet sheet = workbook.getSheet(‘Sheet1’)
// cell A2
Row row = sheet.createRow(1)
Cell cell = row.createCell(0)
cell.setCellValue(GlobalVariable.bookingId)
FileOutputStream fos = new FileOutputStream(location)
workbook.write(fos)
fos.close()
fis.close()