Solved
Forum Discussion
Perchishka
9 years agoOccasional Contributor
Hello!
I tried this code
assert context.Response def parsedXml = new XmlSlurper().parseText(context.response) def dt = parsedXml.'**'.find { it.name() == 'PS_SUBSCRIBE_DATA_290.CHANGED_DATE'} as String log.info( parsedXml ) context.TestCase.setPropertyValue('CHANGED_DATE', dt.substring(0, dt.lastIndexOf(".")))
and this message appears in logs:
Wed Mar 01 11:55:52 MSK 2017:INFO:subscribed
but it is not a response of JDBS request, It is a response of the first Test step in this Test case (((
And as a result i have an error:
"Cannot invoke method lastIndexOf() on null object"
Then I decided to make some changes:
assert context.ResponseasXML def parsedXml = new XmlSlurper().parseText(context.ResponseasXML) def dt = parsedXml.'**'.find { it.name() == 'PS_SUBSCRIBE_DATA_290.CHANGED_DATE'} as String log.info( dt ) context.TestCase.setPropertyValue('CHANGED_DATE', dt.substring(0, dt.lastIndexOf(".")))
and next message appears in logs:
Wed Mar 01 12:52:48 MSK 2017:INFO:2017-03-01 11:22:47.036
And this is what I need
But i have an error:
"Cannot invoke method setPropertyValue() on null object"
Could you help me, please?
What should I change?
- Perchishka9 years agoOccasional Contributor
Thank you, very much!
I did it!
assert context.ResponseasXML def parsedXml = new XmlSlurper().parseText(context.ResponseasXML) def dt = parsedXml.'**'.find { it.name() == 'PS_SUBSCRIBE_DATA_290.CHANGED_DATE'} as String def dd = dt.substring(0, dt.lastIndexOf(".")) log.info( dd ) context.testCase.setPropertyValue('CHANGED_DATE', dd)