This sample does the trick.
def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer)
def propertyUrl = testRunner.testCase.getPropertyValue("url")
xml.records() {
car(name: 'HSV Maloo', make: 'Holden', year: 2006) {
country('Australia')
record(type: 'speed', propertyUrl)
}
car(name: 'Royale', make: 'Bugatti', year: 1931) {
country('France')
record(type: 'price', 'Most Valuable Car at $15 million')
}
}
def records = new XmlSlurper().parseText(writer.toString())
xmlString = writer.toString()
log.info(xmlString)
xmlBase64 = xmlString.bytes.encodeBase64()
log.info(xmlBase64);
A couple things stumped me initially
- The specific incantation to get the property from the test
- using 'groovy.xml.MarkupBuilder' instead of just 'MarkupBuilder'
After that, it was a piece of cake :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…