Extrahieren Sie den Wert, der in einer Zeile aus einer Textdatei enthalten ist, mit groovy
Ich möchte den Wert eines Tokens in einer Zeile aus einer Textdatei extrahieren.
Die Zeile aus der Textdatei lautet:
<response>{"timestamp": "2013-11-12T14:55:43Z", "data": {"profile": null, "ticket": "f644231-6d46-44c7-add6-de3a4422871e", </response>
groovy Datei ist:
// read the file from path
def file = new File('c:/tmp/response.txt')
// for example read line by line
def data= file.eachLine { line ->
// check if the line contains your data
if(line.contains('"ticket":')){
return line
}
}
testRunner.testCase.testSuite.project.setPropertyValue('ticket',data)
So speichert es hier keinen Wert in meinem variablen Ticket. Jede Hilfe, bitte