Printing test case name in custom keyword

Hi Guys,

Is there any way to print test case name inside custom keyword?
I have created a Login custom keyword and I have to use different Login id’s for some test case.

I want to use like this:
public static void Login(String username, String password) {
if(testcase ==‘some testcase name’)
WebUI.setText(findTestObject(’’), password)‘Page_LoginPage/Page_SingPass Login/button_LoginSingPassID’))

And I have stored the Login Id’s and Password in excel in Data File like this:
|LoginID | Password |
|S6005044I | MyInfo2o15 |
|S6005045G | |
|S6005064C | |

Please help.


check this page

Thanks for the above link,I tried using the above method, its giving error in GlobalVariable.currentTestCaseId…
What value do I have to set against current testCaseId under Profile> default?


add this as String in profiles file (default)


example use
//list of testcase names
List <String> testCases = new ArrayList<>()

def tcName = GlobalVariable.currentTestCaseId //get current testcase name
String[] parts = tcName.split("/"); //split it to using delimeter /
String one = parts[parts.length-1];
String two = parts[parts.length-2];
String three = parts[parts.length-3];
println three
println two
println one

//loop testcases to find out wanted
for (String s: testCases){
	if (one.equals(s)){
		println ("DEBUG testcase name: "+one)

Thank you @Timo_Kuisma :slight_smile: Its working for me now!

You have to add currentTestCaseId variable inside your Profiles. or you can simply remove or comment that line of code