我可以在 SOAPUI Groovy 脚本中暂停控制台输入吗?

发布于 2024-12-21 21:38:59 字数 327 浏览 5 评论 0原文

我在 SoapUI 中有一个 groovy 脚本,它可以访问 Web 服务 - 我希望在附加分析器之前先预热几分钟,所以我让脚本在预热期间运行,然后等我连接分析器后按回车键。有没有办法在 groovy 脚本中要求用户输入?

我尝试了类似的方法,但总是出现 IOException:

log.info "Press return when ready..."
System.in.withReader {
    answer = it.readLine() // java.io.IOException: Stream closed
}

感谢您的任何提示。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

耀眼的星火 2024-12-28 21:38:59

这是获取用户数据的最简单方法!

def ui = com.eviware.soapui.support.UISupport;
ui.prompt("Write data u want","Data getter");

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");
¢好甜 2024-12-28 21:38:59

让我建议您在模式消息框而不是控制台上暂停。下面是带有消息框的示例代码,该消息框在您关闭它时只是等待:

def alert = com.eviware.soapui.support.UISupport;
alert.showInfoMessage("Press return when ready...")

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...")
木緿 2024-12-28 21:38:59

只需在提问前写“def”即可

System.in.withReader {
     def answer = it.readLine() // java.io.IOException: Stream closed
}

just write "def" before aswer

System.in.withReader {
     def answer = it.readLine() // java.io.IOException: Stream closed
}
稚然 2024-12-28 21:38:59

使用java 6和groovy,你可以做

System.console().readLine "press return"

这是否在soapui脚本中工作是另一回事......:-/

With java 6 and groovy, you can do

System.console().readLine "press return"

Whether this works in a soapui script is another matter... :-/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文