Reputation: 357
Using Karate, I would like to know, if it is possible to set If condition without necessity of calling different feature file (and not using JavaScript) -> using block of Karate feature file code in condition:
e.g. it should be possible to do something like that?
* if (variable==1) {
* delay(3000)
* retry().click('{button[3]/span}Text1')
}
{
* retry().click('{button[2]/span}Text2')
* delay(3000)
}
Is it possible to do somehow like this without using separate feature file with only few rows of code? Do you have any advice?
Upvotes: 1
Views: 207
Reputation: 58058
Yes, use the eval
keyword - and you can do "pure" JS and on multiple lines:
* eval
"""
if (variable == 1) {
delay(3000);
retry().click('{button[3]/span}Text1');
} else {
retry().click('{button[2]/span}Text2');
delay(3000);
}
"""
By the way, since you seem to be doing a lot of advanced testing, I suggest you start using the 1.0 RC version so that you don't get any surprises and you can provide feedback also: https://github.com/intuit/karate/wiki/1.0-upgrade-guide
Upvotes: 1