问题
I've got a groovy script in SoapUI that pokes at a web service - I want things to warm up for a few minutes before I attach a profiler, so I'd the script to run for the warmup period, then wait for me to press return after I've attached the profiler. Is there a way to ask for user input in the groovy script?
I tried something like this, but it always gets an IOException:
log.info "Press return when ready..."
System.in.withReader {
answer = it.readLine() // java.io.IOException: Stream closed
}
Thanks for any tips.
回答1:
Let me propose you to pause on modal message box instead of console. Below is sample code with a message box that simply waits while you close it:
def alert = com.eviware.soapui.support.UISupport;
alert.showInfoMessage("Press return when ready...")
回答2:
Here is a most easy way to get user data!
def ui = com.eviware.soapui.support.UISupport;
ui.prompt("Write data u want","Data getter");
回答3:
just write "def" before aswer
System.in.withReader {
def answer = it.readLine() // java.io.IOException: Stream closed
}
回答4:
With java 6 and groovy, you can do
System.console().readLine "press return"
Whether this works in a soapui script is another matter... :-/
来源:https://stackoverflow.com/questions/8567844/can-i-pause-for-console-input-in-a-soapui-groovy-script