Save a test case variable into the execution profile

I have a line of code where it will create an ExcelSheet with datetime added into the name in order to differentiate the files from each other. For example: “QATestResults_202309151125.xlsx”

I’m planning to have multiple test suites, each one testing a certain feature of a mobile app, and run them all sequentially in a test suite collection. All of those test suites will be creating their own worksheet but they will all share the same ExcelSheet (the aforementioned one).

My issue is that I think inputting the current datetime into the execution profile is inefficient and that I can probably make it more automatic by writing a line of code in a test case where it will save the current datetime+fileName into the execution profile like so:

Date todaysDate = new Date();
def formattedDate = todaysDate.format("ddMMMyyyyhhmmss");

//create excel file, then store into VariableCollections for later use (due to "formattedDate" naming format)
String excelFile = "D:\\work\\Katalon projects\\QA test results\\Booking Class Verification (" + formattedDate + ").xlsx"

//pseudocode for saving "excelFile" into Execution profile
//addIntoExcecutionProfile.add(ProfileVariableName, excelFile) or something like that

Is this at all possible or am I better off just inputting the Excel Sheet name into the Execution Profile manually?

1 Like

Katalon Studio does NOT provide any API to update an Execution Profile. Execution Profile is supposed to be updated manually.

An Execution Profile is just a XML file under the <projectDir>/Profiles with a file extension .glbl. If you want to, you can write a custom code to update an Execution Profile. You may want to read the following tutorial.

1 Like

I see. That tutorial might be helpful for my future projects. Thanks for the help.

I’ll just stick to updating the Execution Profile manually for now

You have to write a function for this and also you can enter current date value into Profile using GlobalVaribale

Do you really need to update the xml file on disk?

I suppose you just want to update a GlobalVariable with a string as follows.

import internal.GlobalVariable

Date todaysDate = new Date();
def formattedDate = todaysDate.format("ddMMMyyyyhhmmss");

//create excel file, then store into VariableCollections for later use (due to "formattedDate" naming format)
String p = "D:\\work\\Katalon projects\\QA test results\\Booking Class Verification (" + formattedDate + ").xlsx"

// setting "excelFile" into a GlolVariable 
GlobalVariable.excelFilePath = p
1 Like

Oh, that might be it. It’s much more straightforward than I thought lol. I’ll give it a try, thanks.