[英]Running an external program from Katalon's Groovy / Java test case
In my Katalon project (running on Windoes OS), I like to run an external python
program. 在我的Katalon项目(在Windoes OS上运行)中,我喜欢运行一个外部
python
程序。
I was looking at several examples of how to execute an external program from a Java or Groovy program. 我在看几个如何从Java或Groovy程序执行外部程序的示例。
The problem is that no matter what program I try to run (the python script or even a simple cd
command), I get the following error from Katalon-Studio
: 问题是,无论我尝试运行哪种程序(python脚本,甚至是简单的
cd
命令),我都会从Katalon-Studio
收到以下错误Katalon-Studio
:
[ERROR] - Test Cases/CallPython FAILED because (of) java.io.IOException: Cannot run program "cd": CreateProcess error=2, The system cannot find the file specified
Here are some of the options I tried: 这是我尝试过的一些选项:
Groovy: Groovy:
println "python myp.py".execute().text
println "cd".execute().text
Java 爪哇
Process p = Runtime.getRuntime().exec("python myp.py");
String[] cmd = ["python", "myp.py"];
Process p = Runtime.getRuntime().exec(cmd);
Process p = Runtime.getRuntime().exec("cd");
If everything has good HOME_PATH this code should help 如果一切都很好,则此代码应有帮助
ProcessBuilder pb = new ProcessBuilder("cmd", "python myp.py")
Process process = pb.start()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.