How to parameterize a part of string in a field of the request in karate

自古美人都是妖i 提交于 2019-12-11 04:28:32

问题


I have a field in my request .I don't want to parameterize the entire field.

"user": "(KGS-ABCDE-GS\n-\n)\n",

The text ABCDE in the above field needs to be updated with a dynamic user always.Rest of the content need not be changed.The user field mentioned above is a part of my whole request.

I am trying to only make the particular test to fetch a value from a variable defined in the feature file.Could you please let me know how this can be done. *def user = "HELLOUSER" "user": "(KGS--GS\n-\n)\n",

Is there a need to have a javascript or some other way to achieve this?


回答1:


Please read the docs: https://github.com/intuit/karate#rules-for-embedded-expressions

* def user = 'HELLOUSER'
* def temp = 'KGS-' + user + '-GS'
* def payload = { user: '#(temp)' }


来源:https://stackoverflow.com/questions/55337271/how-to-parameterize-a-part-of-string-in-a-field-of-the-request-in-karate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!