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: @Keyword
public static void Login(String username, String password) { if(testcase ==‘some testcase name’)
{
WebUI.setText(findTestObject(’’),username)
WebUI.setText(findTestObject(’’), password)
And I have stored the Login Id’s and Password in excel in Data File like this:
|LoginID | Password |
|S6005044I | MyInfo2o15 |
|S6005045G | |
|S6005064C | |
Hello,
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)
currentTestCaseId
<GlobalVariableEntity>
<description></description>
<initValue>''</initValue>
<name>currentTestCaseId</name>
</GlobalVariableEntity>
example use
//list of testcase names
List <String> testCases = new ArrayList<>()
testCases.add("properties")
testCases.add("properties1")
testCases.add("properties2")
testCases.add("properties3")
testCases.add("properties4")
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)
}
}