I am trying to add a print statement to scenarios, but only if certain conditional are met within each scenario. Below is a simple sample of the issue, but this would be used in more complex situations, like if a response shows a delinquency, print the account number, so we can get the delinquency resolved (eventually automating into creating a Jira ticket)
Should this possible using the print command, as I have not been able to get this to work, but I have found a workaround using karate.log.
ie...examples sample 1-3
Background:
* def debugPrint = true
Scenario:
* if (debugPrint) print 'test conditional print'
* if (debugPrint) karate.print('test conditional print')
* if (debugPrint) karate.log('test conditional print')
errors
1)
01: if (debugPrint) print 'test conditional print'
<<<<
org.graalvm.polyglot.PolyglotException: SyntaxError: Unnamed:1:23 Expected ; but found test conditional print
if (debugPrint) print 'test conditional print'
^
2)
01: if (debugPrint) karate.print('test conditional print')
<<<<
org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (print) on com.intuit.karate.core.ScenarioBridge@5f189d38 failed due to: Unknown identifier: print
- <js>.:program(Unnamed:1)
3)
works, but is this the desired approach rather than using print?
07:49:56.455 [com.intuit.karate.cli.Main.main()] INFO com.intuit.karate - test conditional print