Last active
August 14, 2020 06:09
-
-
Save MarkZhangTW/d7dadaad0adbca74f6ced722da817bcd to your computer and use it in GitHub Desktop.
Groovy script for SoapUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Random Request Script | |
def list = [] | |
new File('C:/Users/HSChang/Documents/Work/AML/Requests').eachFile { list << it } | |
def filename = list[new Random().nextInt(list.size())] | |
log.info(filename) | |
def request = context.testCase.getTestStepByName('VaryRequest').getTestRequest() | |
request.setRequestContent(new File(filename.getPath()).getText("UTF-8")) | |
// Save Output Script | |
def filename = "C:/Users/HSChang/Documents/Work/AML/Responses/" + new Date().format("yyyyMMddHHmmssSSS") + ".xml" | |
def response = context.expand( '${VaryRequest#Response}' ) | |
def f = new File(filename) | |
f.write(groovy.xml.XmlUtil.serialize(response), "UTF-8") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment