[英]How to set the value received from the response to .js or json file
I am using the karate api framework to automate web services. 我正在使用空手道api框架来自动化Web服务。 Currently, I am facing problem to set the response value back to the .js or JSON file which I receive from the cucumber feature file.
当前,我面临着将响应值设置回我从黄瓜功能文件接收到的.js或JSON文件的问题。
My response:{"authorizationtoken" : "58102a8c9e074d578edae8f3d5e96001'}
How can I save this to .js or JSON file to reuse them in other scripts [feature files] ? 如何将其保存到.js或JSON文件以在其他脚本[功能文件]中重用?
Thanks in advance. 提前致谢。
You cannot save the value to a .js
or JSON
file provided you don't want to write the value to a json file 如果您不想将值写入json文件,则无法将其保存到
.js
或JSON
文件中
You can assign the value to a variable , let say using a namespacing technique to avoid collision 您可以将值分配给变量,例如使用命名空间技术来避免冲突
var nameSpaceObject = {
authKey : "",
someOtherFunctionIfNecessary :function(){}
};
Then you can call this name space & assign value to it 然后,您可以调用此名称空间并为其分配值
var response = {"authorizationtoken" : "58102a8c9e074d578edae8f3d5e96001' }
nameSpaceObject.authKey = response.authorizationtoken;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.