sathyaraj
9 years agoOccasional Contributor
How to get the specific property value from SOPAUI response?
Whenever i am exeuting the testcases i will get the property value in response as myscore Arun/ten2016-12-20 here the key is myscore and value is Arun/ten2016-12-20. the date will be changing dynmic...
- 9 years ago
The below is the answer for the above post,
/** * Below is the Script Assertion * Retrieves the specified header and asserts against the expected value **/ //Change the header key as needed. def requiredHeaderKey = 'my_client_update' //Change the expected value for the above Header key //Note that below one is using the regular expression to accommodate dynamic date in the header value def expectedRequiredHeaderValue = "Arun/ten\\d{4}-\\d{2}-\\d{2}" //You may not be required to change beyond this point of the script. //Check if the response has headers assert messageExchange.responseHeaders, "There are no headers in the response" //Get & Check if the response has required Header and its value is not empty def requiredHeaderValue = messageExchange.responseHeaders[requiredHeaderKey] assert requiredHeaderValue, "Value of the response header ${requiredHeaderKey} is empty or null" if (requiredHeaderValue instanceof List) { log.info "Requested header value is ${requiredHeaderValue[0]}" assert requiredHeaderValue[0] ==~ expectedRequiredHeaderValue, "Response header value is not matching with the expected value" }
- 9 years ago
Observed similar question got answered here