karate - How to use karate.callSingle() in karate-config.js?
问题描述
I am using an authorization token in all my feature files . To generate the authorization token i need to call a particular feature file(token.feature) . Since I am using the token in all features I keep calling the same feature file again and again. The solution i found is the use of karate.callSingle() in karate-config.js but i dont know how to use karate.callSingle().
解决方案
在karate-config.js
你可以这样做:
var config = { myprop: 'myvalue', myurl: 'somevalue' };
var result = karate.callSingle('classpath:token.feature', config);
config.token = result.token; // assuming you did 'def token'
return config;
现在您的所有功能都可以使用变量token
.
这在文档中进行了解释:https ://github.com/intuit/karate#hooks
推荐阅读
- vba - VBA 可重用循环函数
- azure - 如何生成 .cer 或 .pfx 文件以在 Azure 自动化中创建证书
- python - 退化解决方案:为什么我的模型有这么多自由标量参数
- jquery - 如何将动态选择中的第一个选项设为空白?
- php - 使 php 和 mysql 查询在 WHERE 部分处理“多项选择”的最聪明方法
- python - Python DataFrame 和 for 循环
- swift - SwiftUI - 如何通过函数(使用滑块)更新值?
- azure - 使用图形 api createEvent 发布创建事件的请求引发“OrganizationFromTenantGuidNotFound”错误
- html - 将新 HTML 动态注入网页,并能够访问“新”注入 HTML 中的任何新 DOM 元素
- html - 如何防止 HTML 音频控件在 TAB 键导航期间获得焦点?