[英]How to get a particular value when using karate.fork?
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.当我们将 karate.fork 用于 CLI 命令并需要将一些信息存储在变量中并在下一步中使用时。
for EX - karate.fork('java -version')对于 EX - karate.fork('java -version')
We need to get only the version data alone.我们只需要单独获取版本数据。
Then karate.fork()
is the wrong choice - just use karate.exec()
instead.那么
karate.fork()
是错误的选择 - 只需使用karate.exec()
代替。 It does the same thing, but will block, and also return the console output:它做同样的事情,但会阻塞,并返回控制台 output:
* def output = karate.exec('java -version')
Please read this also for advanced examples: https://stackoverflow.com/a/62911366/143475请阅读此内容以获取高级示例: https://stackoverflow.com/a/62911366/143475
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.