但是,我需要将文件上传到服务器端,然后再用动态值替换文件中的占位符。是否支持动态替换占位符?
我注意到我可以使用'replace'关键字轻松地替换占位符。以下是我的脚本:
给出路径“ common / upload” 和多部分字段读取('classpath:mainFlow / labresultUpload.json')
* def filename = 'PKU.A22backup'
* def someString = read('PKU.A22backup')
* print someString
* replace someString
|token|value|
|labsampleid|'123456'|
* print someString
* multipart file file = { read: "#(filename)", filename: "#(filename)"}
When method post
Then status 200
* def result = response[0].result
但是,我需要动态地替换占位符(这里是指覆盖),然后将文件上传到服务器端。
答案 0 :(得分:0)
您可以选择提供一个值而不是文件名:https://github.com/intuit/karate#multipart-file
* multipart file file = { value: "#(someString)", filename: "#(filename)" }