How to get a particular value when using karate.fork?

Viewed 155

When we use karate.fork for CLI command and need some information from there to be stored in a variable and using it in the next step.

for EX - karate.fork('java -version')

We need to get only the version data alone.

1 Answers

Then karate.fork() is the wrong choice - just use karate.exec() instead. It does the same thing, but will block, and also return the console output:

* def output = karate.exec('java -version')

Please read this also for advanced examples: https://stackoverflow.com/a/62911366/143475

Related