Can I pause for console input in a SOAPUI groovy script?

强颜欢笑 提交于 2019-12-13 04:12:23

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!