The need is to assert roles and fail the test script for few roles if the buttons are not disabled for them. For which I tried performing steps similar to the following:
* assert (role=="DM"||role=="RM"||role=="AVP")
* eval if((role=="DM"||role=="AVP")? read('classpath:extraFeature.feature@checkIfDisabled') : print "options disabled... proceeding further!"
Here I am calling a scenario with tag @checkIfDisabled for the functionality which contains :
* if(exists(#listButton)) karate.fail("Options are enabled... Cannot proceed further! ")
I feel calling a different feature file for this little thing is not worth it. Moreover that as well is not working as expected. Nested if would've been a solution to this. If not or I am wrong with the approach please help me with something that can add to the logic.
I also tried storing the above called scenario code into a variable and call it.
* def fun = if(exists(#listButton)) karate.fail("Options are enabled... Cannot proceed further! ")
* call fun
But the error statement was something like, "this variable is not callable." Which I understand is something wrong from my side. But some hit and trials I did in search of an alternative to nested if. Any suggestions or way to deal this?
Thanks!