Use Case: Because I have a lot of profiles to test multiple Mobile Apps I want to create a logic within my groovy script to look at the “Profile” Name. That profile name is part of the GlobalVariableEntities
For example in the XML view it looks like this:

My code:
String profilesName = GlobalVariableEntities.get(“name”)
https://docs.katalon.com/katalon-studio/docs/execution-profile-v54.html
How do I grab the name of the Profile Name?
In the <projectDir>/Profiles
directory, you find some *.glbl
files. I think the file name xxxx.glbl
has the format of Profile name
plus .glbl
. So you do not have to parse XML. You want to scan the Profiles directory to find the file names.
A test case:
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.util.stream.Collectors
import com.kms.katalon.core.configuration.RunConfiguration
Path projectDir = Paths.get(RunConfiguration.getProjectDir())
Path profileDir = projectDir.resolve('Profiles')
List<String> profileNames = []
for (Path p : Files.list(profileDir).collect(Collectors.toList())) {
String name = p.getFileName().toString().replace('.glbl','') // default.glbl -> default
profileNames.add(name)
}
println profileNames
This test case will emit a list of Profile names like this:
[develop, default]
2 Likes
@kazurayam
It worked however, I want to only grab the profile name that I am executing.
OK, then
import com.kms.katalon.core.configuration.RunConfiguration
println "Execution profile ${RunConfiguration.getExecutionProfile()} is selected"
1 Like
Thank you , YOU THE BEST!!
BOWING DOWN TO YOU