Using Switch-Case to run a set of steps based on a specific profile

Hi all

Is there a way to use “Switch-Case” statement such that based on what profile I select only a set of steps are executed within a Test Case? The profile selected should be indicated using global variables I am guessing.

Any leads on how can I make this happen would be much helpful. Thanks in advance.
jj

1 Like

This might help.

1 Like

Maybe this :

switch(GlobalVariable.ProfileName)
{
case(“User”):
//Do Test here
break;
case(“Admin”):
//Do Test here
break;
case(“Other important user”):
//Do Test here
break;
}

Perfect, what I was looking for. Thanks @Nilau .

This is what I came up with based on the code snippet that you provided.

Script:
Assuming that a variable named ‘sdMessagingAccountName is created within every profile that you choose to run.

switch (GlobalVariable.sdMessagingAccountName) {
    case ' █████ Nexus 6':
        println('\n\n\nNexus Case steps\n\n\n\n\n')

    break
case 'Google Pixel XL':
    println('\n\n\n\nPixels steps\n\n\n\n')

    break
default:
    break

}

Following image shows the execution,