Better way to implement dynamic datetime when reading a file in Karate

Viewed 40
* def now = "2022-03-21 04:30:01"
* def data = karate.jsonPath(read("data.csv"),'$[?(@.TC_ID=="'+TC_ID+'")]')

Records in csv file


|TC_ID  |DATA                           |
|TC_0001|{"VALUE1":"","VALUE2":'#(now)'}|
|TC_0001|{"VALUE1":"","VALUE2":"<now>"} |

How to replace VALUE2 field value with "now" variable? Trying to use replace function but I think it only works with text enclosed with single quotes.

Main goal is for VALUE2 json field to dynamically have the current datetime value in YYYY-MM-DD hh:mm:ss format

0 Answers
Related