coopernico46
7 years agoOccasional Contributor
How to extract a value from a label if the label is repeated
Hi all I'm newbie with SOAP but i'm trying to do my best with my very first TestSet automation. At the moment (most of the test case is done) i have only one issue, i don't know how to look i...
- 7 years ago
As stated, using find you will only get the first result, so no issues with multiple results. The alternative would be findAll.
To solve the error you just need to make sure the result for categoryCode is a String by getting the text(). Same thing as the line above it.
String categoryCode = new XmlSlurper().parseText(context.response)
.CategoryOption
.find {it.PriceInfos.PriceInfo.find { it.'@BreakdownType'.text() == "02 A" }}
.'@PricedCategoryCode'.text()
context.testCase.setPropertyValue('CategoryList', categoryCode)Sorry I missed this before.
- 7 years ago
coopernico46,
See demo script. (use "log.info" instead of println)See the colored text (changes)
def categoryCode = new XmlSlurper().parseText(context.response).'**'.find{ it.PriceInfos.PriceInfo.find { it.'@BreakdownType'.text() == "02 A" } }.@PricedCategoryCode?.text() context.testCase.setPropertyValue('PricedCategoryCode', categoryCode)