Scenario: Test
* def contentType = 'text/event-stream'
* def response =
"""
<data contentLength="5930" contentType="text/event-stream;charset=UTF-8"><![CDATA[
data:
}
}
This works and asserts correctly but this is contains and i would need to have the value known beforehand
And match jsonresponse.data._ contains '00000000000000000000abc'
This works and fails correctly but this is contains and i would need to have the value known beforehand
And match jsonresponse.data._ contains '123456789'
Thanks in advance
You need to convert that stuff into a valid JSON. Refer type conversion: https://github.com/intuit/karate#type-conversion
For the given response, this will convert the multiple rows into a single JSON array.
* def data = /data
* print data
* def data = data.replaceAll('data:', '').replaceAll('}', '},')
* json data = '[' + data + ']'
* print data
Now you can do normal JsonPath processing.
* def numbers = $data[*].groundNumber
* match numbers == ['00000000000000000000123', '00000000000000000000456', '00000000000000000000789', '00000000000000000000000']